Пример #1
0
//Check for errors
$ERRORS->Check('/index.php?page=password_recovery');
####################################################################
## The actual script begins here
//assume failure
$success = false;
//Let's setup our token
$token = new Tokens();
//Set the account ID to be included as salt
$token->setIdentifier($row[$columns['id']]);
//Set the application string so the token is only valid for this app
$token->setApplication('PRECOVER');
//Set the token expiration time
$token->setExpiration($emailTokenLifetime);
//Save the user ID under the token
$token->setExternalData($row);
//Generate a key for the token
$token->generateKey();
//get the encoded key
$key = $token->get_encodedToken();
//register the token
$tokenReg = $token->registerToken();
//continue only if the key was successfully registered
if ($tokenReg === true) {
    //update the account event
    $update = $DB->prepare("UPDATE `account_data` SET `event` = UPPER(:event) WHERE `id` = :id LIMIT 1;");
    $update->bindParam(':id', $row[$columns['id']], PDO::PARAM_INT);
    $update->bindParam(':event', $event, PDO::PARAM_STR);
    $update->execute();
    unset($update);
    ############################################################################