diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index d3d754cd..ffe69db1 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -406,9 +406,9 @@ class Statistics extends Base { * Admin panel specific query * @return data array User settings and shares **/ - public function getAllUserStats($filter='%') { + public function getAllUserStats($filter='%',$limit=1,$start=0) { $this->debug->append("STA " . __METHOD__, 4); - $stmt = $this->mysqli->prepare(" + $sql = " SELECT a.id AS id, a.is_admin as is_admin, @@ -417,18 +417,56 @@ class Statistics extends Base { a.username AS username, a.donate_percent AS donate_percent, a.email AS email - FROM " . $this->user->getTableName() . " AS a - WHERE - a.username LIKE ? - GROUP BY username - ORDER BY username"); - if ($this->checkStmt($stmt) && $stmt->bind_param('s', $filter) && $stmt->execute() && $result = $stmt->get_result()) { + FROM " . $this->user->getTableName() . " AS a"; + if (is_array($filter)) { + $aFilter = array(); + foreach ($filter as $key => $value) { + if (isset($value) && $value != "" ) { + switch ($key) { + case 'account': + $aFilter[] = "a.username LIKE ?"; + $this->addParam('s', $value); + break; + case 'email': + $aFilter[] = "a.email LIKE ?"; + $this->addParam('s', $value); + break; + case 'is_admin': + $aFilter[] = "a.is_admin = ?"; + $this->addParam('i', $value); + break; + case 'is_locked': + $aFilter[] = "a.is_locked = ?"; + $this->addParam('i', $value); + break; + case 'no_fees': + $aFilter[] = "a.no_fees = ?"; + $this->addParam('i', $value); + break; + } + } + } + } + if (!empty($aFilter)) { + $sql .= " WHERE "; + $sql .= implode(' AND ', $aFilter); + } + $sql .= " + ORDER BY username + LIMIT ?,?"; + $this->addParam('i', $start); + $this->addParam('i', $limit); + $stmt = $this->mysqli->prepare($sql); + if ($this->checkStmt($stmt) && call_user_func_array( array($stmt, 'bind_param'), $this->getParam()) && $stmt->execute() && $result = $stmt->get_result()) { // Add our cached shares to the users + $aUsers = array(); while ($row = $result->fetch_assoc()) { $row['shares'] = $this->getUserShares($row['id']); $aUsers[] = $row; } - return $aUsers; + if (count($aUsers) > 0) { + return $aUsers; + } } return $this->sqlError(); } diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 66a14365..2d0e606f 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -153,7 +153,7 @@ class Worker extends Base { * @param limit int * @return mixed array Workers and their settings or false **/ - public function getAllWorkers($iLimit=0, $interval=600) { + public function getAllWorkers($iLimit=0, $interval=600, $start=0) { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT id, username, password, monitor, @@ -191,8 +191,8 @@ class Worker extends Base { WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL ? SECOND) )) AS avg_difficulty FROM $this->table AS w - ORDER BY hashrate DESC LIMIT ?"); - if ($this->checkStmt($stmt) && $stmt->bind_param('iiiiiiiii', $interval, $interval, $interval, $interval, $interval, $interval, $interval, $interval, $iLimit) && $stmt->execute() && $result = $stmt->get_result()) + ORDER BY hashrate DESC LIMIT ?,?"); + if ($this->checkStmt($stmt) && $stmt->bind_param('iiiiiiiiii', $interval, $interval, $interval, $interval, $interval, $interval, $interval, $interval, $start, $iLimit) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_all(MYSQLI_ASSOC); return $this->sqlError('E0057'); } diff --git a/public/include/pages/admin/poolworkers.inc.php b/public/include/pages/admin/poolworkers.inc.php index 54ea4e3c..814d6c07 100644 --- a/public/include/pages/admin/poolworkers.inc.php +++ b/public/include/pages/admin/poolworkers.inc.php @@ -8,11 +8,16 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) { die("404 Page not found"); } - $iActiveWorkers = $worker->getCountAllActiveWorkers(); - $aWorkers = $worker->getAllWorkers($iActiveWorkers); +// Some defaults +$interval = 600; +$iActiveWorkers = $worker->getCountAllActiveWorkers(); +$iActiveWorkers > 30 ? $iLimit = 30 : $iLimit = $iActiveWorkers; +empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start']; - $smarty->assign('WORKERS', $aWorkers); +$aWorkers = $worker->getAllWorkers($iLimit, $interval, $start); +$smarty->assign('LIMIT', $iLimit); +$smarty->assign('WORKERS', $aWorkers); $smarty->assign('CONTENT', 'default.tpl'); ?> diff --git a/public/include/pages/admin/user.inc.php b/public/include/pages/admin/user.inc.php index e6fcacaa..f3d28dbb 100644 --- a/public/include/pages/admin/user.inc.php +++ b/public/include/pages/admin/user.inc.php @@ -9,9 +9,16 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) { die("404 Page not found"); } -$aRoundShares = $statistics->getRoundShares(); +// Some defaults +$iLimit = 30; +$smarty->assign('LIMIT', $iLimit); +empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start']; +$smarty->assign('ADMIN', array('' => '', '0' => 'No', '1' => 'Yes')); +$smarty->assign('LOCKED', array('' => '', '0' => 'No', '1' => 'Yes')); +$smarty->assign('NOFEE', array('' => '', '0' => 'No', '1' => 'Yes')); -switch (@$_POST['do']) { +// Catch our JS queries to update some settings +switch (@$_REQUEST['do']) { case 'lock': $supress_master = 1; // Reset user account @@ -31,27 +38,42 @@ case 'admin': break; } -if (@$_POST['query']) { - // Fetch requested users - $aUsers = $statistics->getAllUserStats($_POST['query']); +// Gernerate the GET URL for filters +if (isset($_REQUEST['filter'])) { + // Fetch round shares for estimates + $aRoundShares = $statistics->getRoundShares(); - // Add additional stats to each user - foreach ($aUsers as $iKey => $aUser) { - $aBalance = $transaction->getBalance($aUser['id']); - $aUser['balance'] = $aBalance['confirmed']; - $aUser['hashrate'] = $statistics->getUserHashrate($aUser['id']); - - if ($config['payout_system'] == 'pps') { - $aUser['sharerate'] = $statistics->getUserSharerate($aUser['id']); - $aUser['difficulty'] = $statistics->getUserShareDifficulty($aUser['id']); - $aUser['estimates'] = $statistics->getUserEstimates($aUser['sharerate'], $aUser['difficulty'], $user->getUserDonatePercent($aUser['id']), $user->getUserNoFee($aUser['id']), $statistics->getPPSValue()); - } else { - $aUser['estimates'] = $statistics->getUserEstimates($aRoundShares, $aUser['shares'], $aUser['donate_percent'], $aUser['no_fees']); - } - $aUsers[$iKey] = $aUser; + // Create filter URL for pagination arrows + $strFilters = ''; + foreach (@$_REQUEST['filter'] as $filter => $value) { + $filter = "filter[$filter]"; + $strFilters .= "&$filter=$value"; + } + $smarty->assign('FILTERS', $strFilters); + + // Fetch requested users + if ($aUsers = $statistics->getAllUserStats($_REQUEST['filter'], $iLimit, $start)) { + // Add additional stats to each user + foreach ($aUsers as $iKey => $aUser) { + $aBalance = $transaction->getBalance($aUser['id']); + $aUser['balance'] = $aBalance['confirmed']; + $aUser['hashrate'] = $statistics->getUserHashrate($aUser['id']); + + if ($config['payout_system'] == 'pps') { + $aUser['sharerate'] = $statistics->getUserSharerate($aUser['id']); + $aUser['difficulty'] = $statistics->getUserShareDifficulty($aUser['id']); + $aUser['estimates'] = $statistics->getUserEstimates($aUser['sharerate'], $aUser['difficulty'], $user->getUserDonatePercent($aUser['id']), $user->getUserNoFee($aUser['id']), $statistics->getPPSValue()); + } else { + $aUser['estimates'] = $statistics->getUserEstimates($aRoundShares, $aUser['shares'], $aUser['donate_percent'], $aUser['no_fees']); + } + $aUsers[$iKey] = $aUser; + } + + // Assign our variables + $smarty->assign("USERS", $aUsers); + } else { + $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any users', 'TYPE' => 'errormsg'); } - // Assign our variables - $smarty->assign("USERS", $aUsers); } diff --git a/public/templates/mpos/admin/poolworkers/default.tpl b/public/templates/mpos/admin/poolworkers/default.tpl index b9b7cc8a..3af8fece 100644 --- a/public/templates/mpos/admin/poolworkers/default.tpl +++ b/public/templates/mpos/admin/poolworkers/default.tpl @@ -1,6 +1,25 @@
-

{count($WORKERS)} Current Active Pool Workers

- +

{$GLOBAL.workers} Current Active Pool Workers

+ + + +
+ + + + + + +
+{if $smarty.request.start|default:"0" > 0} + +{else} + +{/if} + + +
+ @@ -14,7 +33,7 @@ {nocache} {section worker $WORKERS} - + @@ -28,6 +47,6 @@ {/section} {/nocache} - -
Worker Name
{$WORKERS[worker].username|escape} {$WORKERS[worker].password|escape}
+ +
diff --git a/public/templates/mpos/admin/user/default.tpl b/public/templates/mpos/admin/user/default.tpl index 7a8f2b0f..522fd447 100644 --- a/public/templates/mpos/admin/user/default.tpl +++ b/public/templates/mpos/admin/user/default.tpl @@ -22,13 +22,65 @@ } +
+

User Search

+
+
+ + + + + + + + + +
+{if $smarty.request.start|default:"0" > 0} + +{else} + +{/if} + + +
+
+ + +
+
+ + +
+
+ + {html_options name="filter[is_admin]" options=$ADMIN selected=$smarty.request.filter.is_admin|default:""} +
+
+ + {html_options name="filter[is_locked]" options=$LOCKED selected=$smarty.request.filter.is_locked|default:""} +
+
+ + {html_options name="filter[no_fees]" options=$NOFEE selected=$smarty.request.filter.no_fees|default:""} +
+
    +
  • Note: Text search fields support '%' as wildcard.
  • +
+
+ + +

User Information

-
- +
@@ -87,34 +139,5 @@ {/section} {/nocache} - - - - - - - -{if $GLOBAL.config.payout_system != 'pps'} - - -{else} - -{/if} - - - - - -
ID
IDUsernameE-MailShares  Hashrate  Est. Donation  Est. Payout   Est. 24 Hours   Balance   AdminLockedNo Fees
-