diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 42af02de..2960bfe7 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -176,6 +176,40 @@ class Worker { return false; } + /** + * Fetch all workers for admin panel + * @param limit int + * @return mixed array Workers and their settings or false + **/ + public function getAllWorkers($iLimit=0) { + $this->debug->append("STA " . __METHOD__, 4); + $stmt = $this->mysqli->prepare(" + SELECT id, username, password, monitor, difficulty, + ( + SELECT + IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0), 0) AS hashrate + FROM " . $this->share->getTableName() . " + WHERE + username = w.username + AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) + ( + SELECT + IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0), 0) AS hashrate + FROM " . $this->share->getArchiveTableName() . " + WHERE + username = w.username + AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) AS hashrate + FROM $this->table AS w + ORDER BY hashrate DESC LIMIT ?"); + if ($this->checkStmt($stmt) && $stmt->bind_param('i', $iLimit) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_all(MYSQLI_ASSOC); + // Catchall + $this->setErrorMessage('Failed to fetch workers'); + $this->debug->append('Fetching workers failed: ' . $this->mysqli->error); + return false; + } + /** * Get all currently active workers in the past 10 minutes * @param none diff --git a/public/include/pages/admin/poolworkers.inc.php b/public/include/pages/admin/poolworkers.inc.php new file mode 100644 index 00000000..54ea4e3c --- /dev/null +++ b/public/include/pages/admin/poolworkers.inc.php @@ -0,0 +1,18 @@ +isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) { + header("HTTP/1.1 404 Page not found"); + die("404 Page not found"); +} + + $iActiveWorkers = $worker->getCountAllActiveWorkers(); + $aWorkers = $worker->getAllWorkers($iActiveWorkers); + + $smarty->assign('WORKERS', $aWorkers); + +$smarty->assign('CONTENT', 'default.tpl'); + +?> diff --git a/public/templates/mmcFE/admin/poolworkers/default.tpl b/public/templates/mmcFE/admin/poolworkers/default.tpl new file mode 100644 index 00000000..f7afe308 --- /dev/null +++ b/public/templates/mmcFE/admin/poolworkers/default.tpl @@ -0,0 +1,34 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="{count($WORKERS)} Current Active Pool Workers"} +
+ + + + + + + {if $GLOBAL.config.disable_notifications != 1}{/if} + + + + + {nocache} + {section worker $WORKERS} + + + + + + {if $GLOBAL.config.disable_notifications != 1} + + {/if} + + + + {/section} + {/nocache} + +
Worker NamePasswordActiveMonitorKhash/sDifficulty
{$WORKERS[worker].username|escape}{$WORKERS[worker].password|escape} + + {$WORKERS[worker].hashrate|number_format|default:"0"}{if $WORKERS[worker].hashrate > 0}{$WORKERS[worker].difficulty|number_format:"2"|default:"0"}{else}0{/if}
+
+{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index c7f762e9..1986814e 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -21,6 +21,7 @@
  • Transactions
  • Settings
  • News
  • +
  • Pool Workers
  • {/if} diff --git a/public/templates/mpos/admin/poolworkers/default.tpl b/public/templates/mpos/admin/poolworkers/default.tpl new file mode 100644 index 00000000..5d721421 --- /dev/null +++ b/public/templates/mpos/admin/poolworkers/default.tpl @@ -0,0 +1,31 @@ +
    +

    {count($WORKERS)} Current Active Pool Workers

    + + + + + + + {if $GLOBAL.config.disable_notifications != 1}{/if} + + + + + {nocache} + {section worker $WORKERS} + + + + + + {if $GLOBAL.config.disable_notifications != 1} + + {/if} + + + + {/section} + {/nocache} + +
    Worker NamePasswordActiveMonitorKhash/sDifficulty
    {$WORKERS[worker].username|escape}{$WORKERS[worker].password|escape}{$WORKERS[worker].hashrate|number_format|default:"0"}{if $WORKERS[worker].hashrate > 0}{$WORKERS[worker].difficulty|number_format:"2"|default:"0"}{else}0{/if}
    +
    diff --git a/public/templates/mpos/global/navigation.tpl b/public/templates/mpos/global/navigation.tpl index af922939..b5c84ef6 100644 --- a/public/templates/mpos/global/navigation.tpl +++ b/public/templates/mpos/global/navigation.tpl @@ -22,6 +22,7 @@
  • Transactions
  • Settings
  • News
  • +
  • Pool Workers
  • {/if} {if $smarty.session.AUTHENTICATED|default}