Many thanks for the reply, everyone.
here is the register.php I have tried myself but just end up getting a syntax error.
<?php
require_once('../include/init.php');
// Prepare the errors array
$_errors = array();
// Registration
if (Tools::getValue('register')) {
require_once(APP_DIR.'lib/reCAPTCHA/recaptchalib.php');
$captcha = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"],
Tools::getValue("recaptcha_challenge_field"),
Tools::getValue("recaptcha_response_field"));
if (!Tools::getValue('agree')) {
$_errors []= 'Error #RG0010: '.FRONT_ERROR_RG0010;
} elseif (!$captcha->is_valid) {
$_errors []= 'Error #RG0015: '.FRONT_ERROR_RG0015;
} else {
// Initialize a new user...
$account = new Account();
$_errors = $account->registration(Tools::getValue('register_username'), Tools::getValue('register_password'),
Tools::getValue('repeat_password'), Tools::getValue('email'));
// Register the user if there were no errors in initializing an account
if (!sizeof($_errors)) {
if (!$activation_token = $account->register())
$_errors []= 'Error #RG0009: '.FRONT_ERROR_RG0009;
if ($ref = $session->referral) Referral::add($ref, $account->id);
}
}
if (sizeof($_errors)) {
$template = $twig->loadTemplate('index.html');
$template->display(array(
'registration_errors' => $_errors,
'recaptcha' => recaptcha_get_html(RECAPTCHA_PUBLIC_KEY),
'goto' => 'registration',
'post' => $_POST));
exit();
} else {
Tools::redirect('register.php?send_activation&token='.$activation_token);
}
} else
// Account activation
if (Tools::getValue('activate', 'null') != 'null' or Tools::getValue('send_activation', 'null') != 'null') {
$_errors = array();
// Initialize the activation
$activation = Activation::getByField(array('token' => Tools::getValue('token')));
if (!($activation->id)) $_errors []= 'Error #RG0011: '.FRONT_ERROR_RG0011;
else {
$account = new Account($activation->id_account);
if (!$account->id) Error::get()->report('ACT0003', 'UserID#'.$activation->id_account.' ActivationID#'.$activation->id, CRITICAL_ERROR);
}
$success = false;
// Send activation key
if (Tools::getValue('send_activation', 'null') != 'null') {
if (!Mail::send($account->email, 'activation', array('activation_token' => $activation->token, 'activation_code' => $activation->getCode(), 'account' => $account))) {
Error::get()->report('MAIL0001', 'UserID#'.$account->id, NOTICE_ERROR);
$_errors []= 'Error #RG0013: '.FRONT_ERROR_RG0013;
} else $success = true;
}
// Check activation key
if (Tools::getValue('activate', 'null') != 'null' and Tools::getValue('activation_code', 'null') != 'null') {
$activation_code = Tools::getValue('activation_code');
if ($activation_code != $activation->getCode()) {
$_errors []= 'Error #RG0012: '.FRONT_ERROR_RG0012;
} elseif(!$activation->success($account)) {
// Activation failed
$_errors []= 'Error #RG0014: '.FRONT_ERROR_RG0014;
} else { // Display successfull activation prompt and mail the welcome message
if (!Mail::send($account->email, 'welcome', array('account' => $account)))
Error::get()->report('MAIL0003', 'UserID#'.$account->id, NOTICE_ERROR);
$template = $twig->loadTemplate('activate.html');
$template->display(array(
'success' => true));
exit();
}
}
$template = $twig->loadTemplate('activate.html');
$template->display(array(
'activation_errors' => $_errors,
'activation_success_send' => $success,
'post' => $_POST,
'activation_token' => $activation->token,
'email' => $account->email));
exit();
} else Tools::redirect('/'); // An unknown request to this file
?>