fixed isTokenValid, started work on edit fixes, recaptcha fix test

This commit is contained in:
xisi 2014-01-17 23:43:55 -05:00
parent 3b6a408c3f
commit fed3981979
2 changed files with 14 additions and 11 deletions

View File

@ -38,7 +38,7 @@ class Token Extends Base {
* @param type int Type of token
* @return int 0 or 1
*/
public function isTokenValid($account_id, $token, $type) {
public function isTokenValid($account_id, $token, $type, $checkTimeExplicitly=false) {
if (!is_int($account_id) || !is_int($type)) {
$this->setErrorMessage("Invalid token");
return 0;
@ -47,15 +47,15 @@ class Token Extends Base {
$ctimedata = new DateTime($this->getCreationTime($token));
$checktime = $ctimedata->getTimestamp() + $expiretime;
$now = time();
// if start + checktime is LATER than now, ie valid
if ($checktime >= $now) {
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? AND token = ? AND type = ? AND UNIX_TIMESTAMP(time) < UNIX_TIMESTAMP(NOW()) LIMIT 1");
} else {
if ($checktime >= $now && $checkTimeExplicitly || !$checkTimeExplicitly) {
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? AND token = ? AND type = ? LIMIT 1");
if ($stmt && $stmt->bind_param('isi', $account_id, $token, $type) && $stmt->execute())
$res = $stmt->get_result();
return $res->num_rows;
return $this->sqlError();
} else {
$this->setErrorMessage("Token has expired or is invalid");
return 0;
}
}

View File

@ -50,6 +50,14 @@ if ($user->isAuthenticated()) {
$ptc++;
}
$_SESSION['POPUP'][] = array('CONTENT' => $popupmsg, 'TYPE' => 'info');
// show our token status
/*$ea_status = array($ea_sent, $ea_editable); $statuses = array(0 => 'no', 1 => 'yes');
$cp_status = array($cp_sent, $cp_editable); $messages = array('Edit Account : ','Change Password : ', 'Withdraw Funds : ');
$wf_status = array($wf_sent, $ewf_editable); $alltokens = array($ea_status,$cp_status,$wf_status);
$tokennum = 0; $tokenpopupmsg = "";
foreach ($alltokens as $atoken) {
$tokenpopupmsg = $message[$messages[$tokennum]]." ".$ea_status[0];
}*/
}
if (isset($_POST['do']) && $_POST['do'] == 'genPin') {
@ -86,11 +94,6 @@ if ($user->isAuthenticated()) {
}
}
} else {
// 2fa - when submitting we want the old token, otherwise we'll take what we can $_GET ... B^)
$ea_token = $updating ? $oldtoken_ea : @$_GET['ea_token'];
$wf_token = $updating ? $oldtoken_wf : @$_GET['wf_token'];
$cp_token = $updating ? $oldtoken_cp : @$_GET['cp_token'];
switch (@$_POST['do']) {
case 'cashOut':
if ($setting->getValue('disable_payouts') == 1 || $setting->getValue('disable_manual_payouts') == 1) {