diff --git a/config.php b/config.php index 78f6d72..2f3c5d1 100644 --- a/config.php +++ b/config.php @@ -692,6 +692,7 @@ 'register' => false, // Send activation mail 'accountRecovery' => false, // Recover username or password through mail 'myaccount_verify_email' => false, // Allow user to verify their email in myaccount page + 'verify_email_points' => 0, // 0 = disabled. Give users points reward for verifying their email 'host' => "mailserver.znote.eu", // Outgoing mail server host. 'securityType' => 'ssl', // ssl or tls 'port' => 465, // SMTP port number - likely to be 465(ssl) or 587(tls) diff --git a/myaccount.php b/myaccount.php index 2b384aa..8ec64cf 100644 --- a/myaccount.php +++ b/myaccount.php @@ -30,11 +30,16 @@ if (isset($_GET['authenticate']) && $config['mailserver']['myaccount_verify_emai $user = (int) $user['id']; $active = (int) $user['active']; $active_email = (int) $user['active_email']; + $verify_points = ($active_email == 0 && $config['mailserver']['verify_email_points'] > 0) + ? ", `points` = `points` + {$config['mailserver']['verify_email_points']}" + : ''; // Enable the account to login if ($active == 0 || $active_email == 0) { - mysql_update("UPDATE `znote_accounts` SET `active`='1', `active_email`='1' WHERE `id`= $user LIMIT 1;"); + $new_activeKey = rand(100000000,999999999); + mysql_update("UPDATE `znote_accounts` SET `active`='1', `active_email`='1', `activekey`='{$new_activeKey}' {$verify_points} WHERE `id`= {$user} LIMIT 1;"); } echo '
Your email has been verified.
'; + if ($verify_points !== '') echo "As thanks for having a verified email, you have received {$config['mailserver']['verify_email_points']} shop points!
"; $user_znote_data['active_email'] = 1; // Todo: Bonus points as thanks for verifying email } else { diff --git a/settings.php b/settings.php index 99a4e75..d970316 100644 --- a/settings.php +++ b/settings.php @@ -43,6 +43,11 @@ if (isset($_GET['success']) === true && empty($_GET['success']) === true) { 'active_email' => '0' ); + // If he had previously verified his email address, remove the previously aquired bonus points + if ($user_znote_data['active_email'] > 0) { + $update_znote_data['points'] = $user_znote_data['points'] - $config['mailserver']['verify_email_points']; + } + user_update_account($update_data); user_update_znote_account($update_znote_data); header('Location: settings.php?success');