commit
f4a1110c48
@ -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();
|
||||
}
|
||||
|
||||
@ -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');
|
||||
}
|
||||
|
||||
@ -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');
|
||||
|
||||
?>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
<article class="module width_3_quarter">
|
||||
<header><h3>{count($WORKERS)} Current Active Pool Workers</h3></header>
|
||||
<table class="tablesorter" cellspacing="0">
|
||||
<header><h3>{$GLOBAL.workers} Current Active Pool Workers</h3></header>
|
||||
<form action="{$smarty.server.PHP_SELF}">
|
||||
<input type="hidden" name="page" value="{$smarty.request.page|escape}" />
|
||||
<input type="hidden" name="action" value="{$smarty.request.action|escape}" />
|
||||
<table cellspacing="0" class="tablesorter">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left">
|
||||
{if $smarty.request.start|default:"0" > 0}
|
||||
<a href="{$smarty.server.PHP_SELF}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&start={$smarty.request.start|escape|default:"0" - $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><i class="icon-left-open"></i></a>
|
||||
{else}
|
||||
<i class="icon-left-open"></i>
|
||||
{/if}
|
||||
</td>
|
||||
<td align="right">
|
||||
<a href="{$smarty.server.PHP_SELF}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&start={$smarty.request.start|escape|default:"0" + $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><i class="icon-right-open"></i></a>
|
||||
</td>
|
||||
</tbody>
|
||||
</form>
|
||||
</table>
|
||||
<table class="tablesorter" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left">Worker Name</th>
|
||||
@ -14,7 +33,7 @@
|
||||
</thead>
|
||||
{nocache}
|
||||
{section worker $WORKERS}
|
||||
<tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left">{$WORKERS[worker].username|escape}</td>
|
||||
<td align="left">{$WORKERS[worker].password|escape}</td>
|
||||
@ -28,6 +47,6 @@
|
||||
</tr>
|
||||
{/section}
|
||||
{/nocache}
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
|
||||
@ -22,13 +22,65 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<article class="module width_full">
|
||||
<header><h3>User Search</h3></header>
|
||||
<div class="module_content">
|
||||
<form action="{$smarty.server.PHP_SELF}">
|
||||
<input type="hidden" name="page" value="{$smarty.request.page|escape}" />
|
||||
<input type="hidden" name="action" value="{$smarty.request.action|escape}" />
|
||||
<input type="hidden" name="do" value="query" />
|
||||
<table cellspacing="0" class="tablesorter">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left">
|
||||
{if $smarty.request.start|default:"0" > 0}
|
||||
<a href="{$smarty.server.PHP_SELF}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&start={$smarty.request.start|escape|default:"0" - $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><i class="icon-left-open"></i></a>
|
||||
{else}
|
||||
<i class="icon-left-open"></i>
|
||||
{/if}
|
||||
</td>
|
||||
<td align="right">
|
||||
<a href="{$smarty.server.PHP_SELF}?page={$smarty.request.page|escape}&action={$smarty.request.action|escape}&start={$smarty.request.start|escape|default:"0" + $LIMIT}{if $FILTERS|default:""}{$FILTERS}{/if}"><i class="icon-right-open"></i></a>
|
||||
</td>
|
||||
</tbody>
|
||||
</table>
|
||||
<fieldset>
|
||||
<label>Account</label>
|
||||
<input size="20" type="text" name="filter[account]" value="{$smarty.request.filter.account|default:""}" />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label>E-Mail</label>
|
||||
<input size="20" type="text" name="filter[email]" value="{$smarty.request.filter.email|default:""}" />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label>Is Admin</label>
|
||||
{html_options name="filter[is_admin]" options=$ADMIN selected=$smarty.request.filter.is_admin|default:""}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label>Is Locked</label>
|
||||
{html_options name="filter[is_locked]" options=$LOCKED selected=$smarty.request.filter.is_locked|default:""}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label>No Fees</label>
|
||||
{html_options name="filter[no_fees]" options=$NOFEE selected=$smarty.request.filter.no_fees|default:""}
|
||||
</fieldset>
|
||||
<ul>
|
||||
<li>Note: Text search fields support '%' as wildcard.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<footer>
|
||||
<div class="submit_link">
|
||||
<input type="submit" value="Search" class="alt_btn">
|
||||
</div>
|
||||
</footer>
|
||||
</form>
|
||||
</article>
|
||||
|
||||
<article class="module width_full">
|
||||
<header>
|
||||
<h3>User Information</h3>
|
||||
<div class="submit_link">{include file="global/pagination.tpl"}</div>
|
||||
</header>
|
||||
<table width="100%" class="tablesorterpager">
|
||||
<table cellspacing="0" width="100%" class="tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center">ID</th>
|
||||
@ -87,34 +139,5 @@
|
||||
{/section}
|
||||
{/nocache}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th align="center">ID</th>
|
||||
<th align="left">Username</th>
|
||||
<th align="left">E-Mail</th>
|
||||
<th align="right">Shares </th>
|
||||
<th align="right">Hashrate </th>
|
||||
{if $GLOBAL.config.payout_system != 'pps'}
|
||||
<th align="right">Est. Donation </th>
|
||||
<th align="right">Est. Payout </th>
|
||||
{else}
|
||||
<th align="right" colspan="2">Est. 24 Hours </th>
|
||||
{/if}
|
||||
<th align="right">Balance </th>
|
||||
<th align="center">Admin</th>
|
||||
<th align="center">Locked</th>
|
||||
<th align="center">No Fees</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<footer>
|
||||
<div class="submit_link">
|
||||
<form action="{$smarty.server.PHP_SELF}" method="POST" id='query'>
|
||||
<input type="hidden" name="page" value="{$smarty.request.page|escape}">
|
||||
<input type="hidden" name="action" value="{$smarty.request.action|escape}">
|
||||
<input type="text" class="pin" name="query" value="{$smarty.request.query|default:"%"|escape}">
|
||||
<input type="submit" value="Query" class="alt_btn">
|
||||
</form>
|
||||
</div>
|
||||
</footer>
|
||||
</article>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user