diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 5a5c19c4..6052eaac 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -43,17 +43,19 @@ class Worker { public function updateWorkers($account_id, $data) { $this->debug->append("STA " . __METHOD__, 4); $username = $this->user->getUserName($account_id); + $iFailed = 0; foreach ($data as $key => $value) { // Prefix the WebUser to Worker name $value['username'] = "$username." . $value['username']; - $stmt = $this->mysqli->prepare("UPDATE $this->table SET password = ?, username = ? WHERE account_id = ? AND id = ?"); - if ($this->checkStmt($stmt)) { - if (!$stmt->bind_param('ssii', $value['password'], $value['username'], $account_id, $key)) return false; - if (!$stmt->execute()) return false; - $stmt->close(); - } + $stmt = $this->mysqli->prepare("UPDATE $this->table SET password = ?, username = ?, monitor = ? WHERE account_id = ? AND id = ?"); + if ( ! ( $this->checkStmt($stmt) && $stmt->bind_param('ssiii', $value['password'], $value['username'], $value['monitor'], $account_id, $key) && $stmt->execute()) ) + $iFailed++; } - return true; + if ($iFailed == 0) + return true; + // Catchall + $this->setErrorMessage('Failed to update ' . $iFailed . ' worker.'); + return false; } /** @@ -64,7 +66,7 @@ class Worker { public function getWorkers($account_id) { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" - SELECT id, username, password, + SELECT id, username, password, monitor, ( SELECT SIGN(COUNT(id)) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS active, ( SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS hashrate FROM $this->table diff --git a/public/templates/mmcFE/account/workers/default.tpl b/public/templates/mmcFE/account/workers/default.tpl index f1b6e875..612bd227 100644 --- a/public/templates/mmcFE/account/workers/default.tpl +++ b/public/templates/mmcFE/account/workers/default.tpl @@ -10,6 +10,7 @@
