Merge pull request #1457 from MPOS/issue-1332

Issue 1332
This commit is contained in:
Sebastian Grewe 2014-01-28 00:18:56 -08:00
commit b783237c2e
5 changed files with 17 additions and 14 deletions

View File

@ -78,10 +78,11 @@ class Share Extends Base {
**/ **/
public function getRoundShares($previous_upstream=0, $current_upstream) { public function getRoundShares($previous_upstream=0, $current_upstream) {
$stmt = $this->mysqli->prepare("SELECT $stmt = $this->mysqli->prepare("SELECT
ROUND(IFNULL(SUM(IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 8) AS total ROUND(IFNULL(SUM(IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 8) AS total
FROM $this->table FROM $this->table AS s
WHERE our_result = 'Y' LEFT JOIN " . $this->user->getTableName() . " AS a
AND id > ? AND id <= ? ON a.username = SUBSTRING_INDEX( s.username , '.', 1 )
WHERE s.id > ? AND s.id <= ? AND s.our_result = 'Y' AND a.is_locked != 2
"); ");
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $previous_upstream, $current_upstream) && $stmt->execute() && $result = $stmt->get_result()) if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $previous_upstream, $current_upstream) && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_object()->total; return $result->fetch_object()->total;
@ -106,7 +107,7 @@ class Share Extends Base {
FROM $this->table AS s FROM $this->table AS s
LEFT JOIN " . $this->user->getTableName() . " AS a LEFT JOIN " . $this->user->getTableName() . " AS a
ON a.username = SUBSTRING_INDEX( s.username , '.', 1 ) ON a.username = SUBSTRING_INDEX( s.username , '.', 1 )
WHERE s.id > ? AND s.id <= ? WHERE s.id > ? AND s.id <= ? AND a.is_locked != 2
GROUP BY username DESC GROUP BY username DESC
"); ");
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $previous_upstream, $current_upstream) && $stmt->execute() && $result = $stmt->get_result()) if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $previous_upstream, $current_upstream) && $stmt->execute() && $result = $stmt->get_result())
@ -153,7 +154,7 @@ class Share Extends Base {
FROM $this->tableArchive AS s FROM $this->tableArchive AS s
LEFT JOIN " . $this->user->getTableName() . " AS a LEFT JOIN " . $this->user->getTableName() . " AS a
ON a.username = SUBSTRING_INDEX( s.username , '.', 1 ) ON a.username = SUBSTRING_INDEX( s.username , '.', 1 )
WHERE s.share_id > ? AND s.share_id <= ? WHERE s.share_id > ? AND s.share_id <= ? AND a.is_locked != 2
GROUP BY account DESC"); GROUP BY account DESC");
if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $iMinId, $iMaxId) && $stmt->execute() && $result = $stmt->get_result()) { if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $iMinId, $iMaxId) && $stmt->execute() && $result = $stmt->get_result()) {
$aData = NULL; $aData = NULL;

View File

@ -71,8 +71,8 @@ class User extends Base {
$field = array('name' => 'no_fees', 'type' => 'i', 'value' => !$this->isNoFee($id)); $field = array('name' => 'no_fees', 'type' => 'i', 'value' => !$this->isNoFee($id));
return $this->updateSingle($id, $field); return $this->updateSingle($id, $field);
} }
public function changeLocked($id) { public function setLocked($id, $value) {
$field = array('name' => 'is_locked', 'type' => 'i', 'value' => !$this->isLocked($id)); $field = array('name' => 'is_locked', 'type' => 'i', 'value' => $value);
return $this->updateSingle($id, $field); return $this->updateSingle($id, $field);
} }
public function changeAdmin($id) { public function changeAdmin($id) {
@ -172,7 +172,7 @@ class User extends Base {
$this->incUserFailed($id); $this->incUserFailed($id);
// Check if this account should be locked // Check if this account should be locked
if (isset($this->config['maxfailed']['login']) && $this->getUserFailed($id) >= $this->config['maxfailed']['login']) { if (isset($this->config['maxfailed']['login']) && $this->getUserFailed($id) >= $this->config['maxfailed']['login']) {
$this->changeLocked($id); $this->setLocked($id, 1);
if ($token = $this->token->createToken('account_unlock', $id)) { if ($token = $this->token->createToken('account_unlock', $id)) {
$aData['token'] = $token; $aData['token'] = $token;
$aData['username'] = $username; $aData['username'] = $username;
@ -204,7 +204,7 @@ class User extends Base {
$this->incUserPinFailed($userId); $this->incUserPinFailed($userId);
// Check if this account should be locked // Check if this account should be locked
if (isset($this->config['maxfailed']['pin']) && $this->getUserPinFailed($userId) >= $this->config['maxfailed']['pin']) { if (isset($this->config['maxfailed']['pin']) && $this->getUserPinFailed($userId) >= $this->config['maxfailed']['pin']) {
$this->changeLocked($userId); $this->setLocked($userId, 1);
if ($token = $this->token->createToken('account_unlock', $userId)) { if ($token = $this->token->createToken('account_unlock', $userId)) {
$username = $this->getUserName($userId); $username = $this->getUserName($userId);
$aData['token'] = $token; $aData['token'] = $token;

View File

@ -9,7 +9,7 @@ if (!isset($_GET['token']) || empty($_GET['token'])) {
} else if (!$aToken = $oToken->getToken($_GET['token'], 'confirm_email')) { } else if (!$aToken = $oToken->getToken($_GET['token'], 'confirm_email')) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to activate your account. Invalid token.', 'TYPE' => 'errormsg'); $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to activate your account. Invalid token.', 'TYPE' => 'errormsg');
} else { } else {
$user->changeLocked($aToken['account_id']); $user->setLocked($aToken['account_id'], 0);
$oToken->deleteToken($aToken['token']); $oToken->deleteToken($aToken['token']);
$_SESSION['POPUP'][] = array('CONTENT' => 'Account activated. Please login.'); $_SESSION['POPUP'][] = array('CONTENT' => 'Account activated. Please login.');
} }

View File

@ -10,7 +10,7 @@ if (!isset($_GET['token']) || empty($_GET['token'])) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to re-activate your account. Invalid token.', 'TYPE' => 'errormsg'); $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to re-activate your account. Invalid token.', 'TYPE' => 'errormsg');
} else { } else {
if (!$config['csrf']['enabled'] || $config['csrf']['enabled'] && $csrftoken->valid) { if (!$config['csrf']['enabled'] || $config['csrf']['enabled'] && $csrftoken->valid) {
if ($user->setUserFailed($aToken['account_id'], 0) && $user->setUserPinFailed($aToken['account_id'], 0) && $user->changeLocked($aToken['account_id'])) { if ($user->setUserFailed($aToken['account_id'], 0) && $user->setUserPinFailed($aToken['account_id'], 0) && $user->setLocked($aToken['account_id'], 0)) {
$oToken->deleteToken($aToken['token']); $oToken->deleteToken($aToken['token']);
$_SESSION['POPUP'][] = array('CONTENT' => 'Account re-activated. Please login.'); $_SESSION['POPUP'][] = array('CONTENT' => 'Account re-activated. Please login.');
} else { } else {
@ -22,4 +22,4 @@ if (!isset($_GET['token']) || empty($_GET['token'])) {
} }
$smarty->assign('CONTENT', 'default.tpl'); $smarty->assign('CONTENT', 'default.tpl');
?> ?>

View File

@ -22,8 +22,10 @@ switch (@$_REQUEST['do']) {
case 'lock': case 'lock':
$supress_master = 1; $supress_master = 1;
// Reset user account // Reset user account
$user->changeLocked($_POST['account_id']);
if ($user->isLocked($_POST['account_id']) == 0) { if ($user->isLocked($_POST['account_id']) == 0) {
$user->setLocked($_POST['account_id'], 2);
} else {
$user->setLocked($_POST['account_id'], 0);
$user->setUserFailed($_POST['account_id'], 0); $user->setUserFailed($_POST['account_id'], 0);
$user->setUserPinFailed($_POST['account_id'], 0); $user->setUserPinFailed($_POST['account_id'], 0);
} }