commit
ec054cd2ef
@ -238,7 +238,7 @@ class User {
|
||||
* @param donat float donation % of income
|
||||
* @return bool
|
||||
**/
|
||||
public function updateAccount($userID, $address, $threshold, $donate) {
|
||||
public function updateAccount($userID, $address, $threshold, $donate, $email) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
$bUser = false;
|
||||
|
||||
@ -257,18 +257,21 @@ class User {
|
||||
$this->setErrorMessage('Donation above allowed 100% limit');
|
||||
return false;
|
||||
}
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$this->setErrorMessage('Invalid email address');
|
||||
return false;
|
||||
}
|
||||
// Number sanitizer, just in case we fall through above
|
||||
$threshold = min($this->config['ap_threshold']['max'], max(0, floatval($threshold)));
|
||||
$donate = min(100, max(0, floatval($donate)));
|
||||
|
||||
// We passed all validation checks so update the account
|
||||
$stmt = $this->mysqli->prepare("UPDATE $this->table SET coin_address = ?, ap_threshold = ?, donate_percent = ? WHERE id = ?");
|
||||
$stmt->bind_param('sddi', $address, $threshold, $donate, $userID);
|
||||
$stmt->execute();
|
||||
if ( $stmt->errno == 0 ) {
|
||||
$stmt->close();
|
||||
$stmt = $this->mysqli->prepare("UPDATE $this->table SET coin_address = ?, ap_threshold = ?, donate_percent = ?, email = ? WHERE id = ?");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('sddsi', $address, $threshold, $donate, $email, $userID) && $stmt->execute())
|
||||
return true;
|
||||
}
|
||||
// Catchall
|
||||
$this->setErrorMessage('Failed to update your account');
|
||||
$this->debug->append('Account update failed: ' . $this->mysqli->error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -356,7 +359,7 @@ class User {
|
||||
$this->debug->append("Fetching user information for user id: $userID");
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
id, username, pin, api_key, admin,
|
||||
id, username, pin, api_key, admin, email,
|
||||
IFNULL(donate_percent, '0') as donate_percent, coin_address, ap_threshold
|
||||
FROM $this->table
|
||||
WHERE id = ? LIMIT 0,1");
|
||||
@ -394,7 +397,7 @@ class User {
|
||||
$this->setErrorMessage( 'Password do not match' );
|
||||
return false;
|
||||
}
|
||||
if (!empty($email1) && !filter_var($email1, FILTER_VALIDATE_EMAIL)) {
|
||||
if (empty($email1) || !filter_var($email1, FILTER_VALIDATE_EMAIL)) {
|
||||
$this->setErrorMessage( 'Invalid e-mail address' );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST
|
||||
break;
|
||||
|
||||
case 'updateAccount':
|
||||
if ($user->updateAccount($_SESSION['USERDATA']['id'], $_POST['paymentAddress'], $_POST['payoutThreshold'], $_POST['donatePercent'])) {
|
||||
if ($user->updateAccount($_SESSION['USERDATA']['id'], $_POST['paymentAddress'], $_POST['payoutThreshold'], $_POST['donatePercent'], $_POST['email'])) {
|
||||
$_SESSION['POPUP'][] = array('CONTENT' => 'Account details updated', 'TYPE' => 'success');
|
||||
} else {
|
||||
$_SESSION['POPUP'][] = array('CONTENT' => 'Failed to update your account: ' . $user->getError(), 'TYPE' => 'errormsg');
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
<tbody><tr><td>Username: </td><td>{$GLOBAL.userdata.username}</td></tr>
|
||||
<tr><td>User Id: </td><td>{$GLOBAL.userdata.id}</td></tr>
|
||||
<tr><td>API Key: </td><td>{$GLOBAL.userdata.api_key}</td></tr>
|
||||
<tr><td>E-Mail: </td><td><input type="text" name="email" value="{$GLOBAL.userdata.email|escape}" size="20"></td></tr>
|
||||
<tr><td>Payment Address: </td><td><input type="text" name="paymentAddress" value="{$smarty.request.paymentAddress|default:$GLOBAL.userdata.coin_address|escape}" size="40"></td></tr>
|
||||
<tr><td>Donation %: </td><td><input type="text" name="donatePercent" value="{$smarty.request.donatePercent|default:$GLOBAL.userdata.donate_percent|escape}" size="4"><font size="1"> [donation amount in percent (example: 0.5)]</font></td></tr>
|
||||
<tr><td>Automatic Payout Threshold: </td><td valign="top"><input type="text" name="payoutThreshold" value="{$smarty.request.payoutThreshold|default:$GLOBAL.userdata.ap_threshold|escape}" size="5" maxlength="5"> <font size="1">[{$GLOBAL.config.ap_threshold.min}-{$GLOBAL.config.ap_threshold.max} LTC. Set to '0' for no auto payout]</font></td></tr>
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<tbody><tr><td>Username:</td><td><input type="text" class="text tiny" name="username" value="{$smarty.post.username|escape}" size="15" maxlength="20"></td></tr>
|
||||
<tr><td>Password:</td><td><input type="password" class="text tiny" name="password1" value="" size="15" maxlength="20"></td></tr>
|
||||
<tr><td>Repeat Password:</td><td><input type="password" class="text tiny" name="password2" value="" size="15" maxlength="20"></td></tr>
|
||||
<tr><td>Email:</td><td><input type="text" name="email1" class="text small" value="{$smarty.post.email1|escape}" size="15"><font size="1"> (Optional) </font></td></tr>
|
||||
<tr><td>Email Repeat:</td><td><input type="text" class="text small" name="email2" value="{$smarty.post.email2|escape}" size="15"><font size="1"> (Optional) </font></td></tr>
|
||||
<tr><td>Email:</td><td><input type="text" name="email1" class="text small" value="{$smarty.post.email1|escape}" size="15"></td></tr>
|
||||
<tr><td>Email Repeat:</td><td><input type="text" class="text small" name="email2" value="{$smarty.post.email2|escape}" size="15"></td></tr>
|
||||
<tr><td>PIN:</td><td><input type="password" class="text pin" name="pin" value="" size="4" maxlength="4"><font size="1"> (4 digit number. <b>Remember this pin!</b>)</font></td></tr>
|
||||
</tbody></table>
|
||||
<input type="submit" class="submit small" value="Register">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user