diff --git a/cronjobs/pplns_payout.php b/cronjobs/pplns_payout.php index 73ce4a17..8d60ae2e 100755 --- a/cronjobs/pplns_payout.php +++ b/cronjobs/pplns_payout.php @@ -40,6 +40,12 @@ if (empty($aAllBlocks)) { $count = 0; foreach ($aAllBlocks as $iIndex => $aBlock) { + // If we have unaccounted blocks without share_ids, they might not have been inserted yet + if (!$aBlock['share_id']) { + $log->logError('E0062: Block has no share_id, not running payouts'); + $monitoring->endCronjob($cron_name, 'E0062', 0, true); + } + // We support some dynamic share targets but fall back to our fixed value // Re-calculate after each run due to re-targets in this loop if ($config['pplns']['shares']['type'] == 'blockavg' && $block->getBlockCount() > 0) { @@ -50,6 +56,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $pplns_target = $config['pplns']['shares']['default']; } + // Fetch our last paid block information if ($iLastBlockId = $setting->getValue('last_accounted_block_id')) { $aLastAccountedBlock = $block->getBlockById($iLastBlockId); } else { diff --git a/cronjobs/proportional_payout.php b/cronjobs/proportional_payout.php index 49ab7a94..59819b29 100755 --- a/cronjobs/proportional_payout.php +++ b/cronjobs/proportional_payout.php @@ -42,6 +42,13 @@ $count = 0; // Table header for account shares $log->logInfo("ID\tUsername\tValid\tInvalid\tPercentage\tPayout\t\tDonation\tFee"); foreach ($aAllBlocks as $iIndex => $aBlock) { + // If we have unaccounted blocks without share_ids, they might not have been inserted yet + if (!$aBlock['share_id']) { + $log->logError('E0062: Block has no share_id, not running payouts'); + $monitoring->endCronjob($cron_name, 'E0062', 0, true); + } + + // Fetch last paid block information if ($iLastBlockId = $setting->getValue('last_accounted_block_id')) { $aLastAccountedBlock = $block->getBlockById($iLastBlockId); } else { diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 30bdb078..bae7ed81 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -30,9 +30,7 @@ class Statistics extends Base { $this->debug->append("STA " . __METHOD__, 4); if ($data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" - SELECT - time FROM " . $this->block->getTableName() . " - ORDER BY id ASC LIMIT 1"); + SELECT IFNULL(MIN(time), 0) AS time FROM " . $this->block->getTableName()); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->time; return false; diff --git a/public/include/config/error_codes.inc.php b/public/include/config/error_codes.inc.php index b48622c3..5eda21da 100644 --- a/public/include/config/error_codes.inc.php +++ b/public/include/config/error_codes.inc.php @@ -65,4 +65,5 @@ $aErrorCodes['E0058'] = 'Worker name and/or password must not be empty'; $aErrorCodes['E0059'] = 'Worker already exists'; $aErrorCodes['E0060'] = 'Failed to add new worker'; $aErrorCodes['E0061'] = 'Failed to delete worker'; +$aErrorCodes['E0062'] = 'Block has no share_id, not running payouts'; ?> diff --git a/public/include/pages/statistics/uptime.inc.php b/public/include/pages/statistics/uptime.inc.php index df5cca83..3e321e7f 100644 --- a/public/include/pages/statistics/uptime.inc.php +++ b/public/include/pages/statistics/uptime.inc.php @@ -5,7 +5,7 @@ if (!defined('SECURITY')) die('Hacking attempt'); if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); - if ($setting->getValue('monitoring_uptimerobot_private_key')) { + if ($setting->getValue('monitoring_uptimerobot_api_keys')) { if ($aStatus = $monitoring->getUptimeRobotStatus()) { $smarty->assign("STATUS", $aStatus); $smarty->assign("UPDATED", $setting->getValue('monitoring_uptimerobot_lastcheck')); diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 42406331..a3dc2f0a 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -69,7 +69,7 @@ $aGlobal = array( 'accounts' => $config['accounts'], 'disable_invitations' => $setting->getValue('disable_invitations'), 'disable_notifications' => $setting->getValue('disable_notifications'), - 'monitoring_uptimerobot_private_key' => $setting->getValue('monitoring_uptimerobot_private_key'), + 'monitoring_uptimerobot_api_keys' => $setting->getValue('monitoring_uptimerobot_api_keys'), 'statistics_ajax_refresh_interval' => $statistics_ajax_refresh_interval, 'price' => array( 'currency' => $config['price']['currency'] ), 'targetdiff' => $config['difficulty'], diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index 32968c99..82754506 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -33,7 +33,7 @@
  • Block Stats
  • Hashrate Graphs
  • Round Stats
  • - {if $GLOBAL.config.monitoring_uptimerobot_private_key|default:"0"}
  • Uptime Stats
  • {/if} + {if $GLOBAL.config.monitoring_uptimerobot_api_keys|default:"0"}
  • Uptime Stats
  • {/if} {else} @@ -49,7 +49,7 @@
  • Round Stats
  • {/if} {if $GLOBAL.acl.uptime.statistics} - {if $GLOBAL.config.monitoring_uptimerobot_private_key|default:"0"}
  • Uptime Stats
  • {/if} + {if $GLOBAL.config.monitoring_uptimerobot_api_keys|default:"0"}
  • Uptime Stats
  • {/if} {/if} {/if} diff --git a/public/templates/mpos/global/navigation.tpl b/public/templates/mpos/global/navigation.tpl index 55e5a369..39c5ee84 100644 --- a/public/templates/mpos/global/navigation.tpl +++ b/public/templates/mpos/global/navigation.tpl @@ -33,7 +33,7 @@
  • Blocks
  • Graphs
  • Round
  • - {if $GLOBAL.config.monitoring_uptimerobot_private_key|default:"0"}
  • Uptime
  • {/if} + {if $GLOBAL.config.monitoring_uptimerobot_api_keys|default:"0"}
  • Uptime
  • {/if} {else}

    Statistics

    @@ -50,7 +50,7 @@
  • Round
  • {/if} {if $GLOBAL.acl.uptime.statistics} - {if $GLOBAL.config.monitoring_uptimerobot_private_key|default:"0"}
  • Uptime
  • {/if} + {if $GLOBAL.config.monitoring_uptimerobot_api_keys|default:"0"}
  • Uptime
  • {/if} {/if} {/if}