+ $res = XDB::query('SELECT uid
+ FROM account_lost_passwords
+ WHERE certificat = {?}', $certif);
+ $ligne = $res->fetchOneAssoc();
+ if (!$ligne) {
+ $page->changeTpl('platal/index.tpl');
+ $page->kill("Cette adresse n'existe pas ou n'existe plus sur le serveur.");
+ }
+
+ $hruid = XDB::fetchOneCell('SELECT hruid
+ FROM accounts
+ WHERE uid = {?}',
+ $ligne['uid']);
+ $page->changeTpl('platal/password.tpl');
+ $page->assign('hruid', $hruid);
+ $page->assign('do_auth', 1);
+ }
+ }
+
+ function handler_register_ext($page, $hash = null)
+ {
+ XDB::execute('DELETE FROM register_pending_xnet
+ WHERE DATE_SUB(NOW(), INTERVAL 1 MONTH) > date');
+ $res = XDB::fetchOneAssoc('SELECT uid, hruid, email
+ FROM register_pending_xnet
+ WHERE hash = {?}',
+ $hash);
+
+ if (is_null($hash) || is_null($res)) {
+ $page->trigErrorRedirect('Cette adresse n\'existe pas ou n\'existe plus sur le serveur.', '');
+ }
+
+ if (Post::has('pwhash') && Post::t('pwhash')) {
+ XDB::startTransaction();
+ XDB::query('UPDATE accounts
+ SET password = {?}, state = \'active\', registration_date = NOW()
+ WHERE uid = {?} AND state = \'pending\' AND type = \'xnet\'',
+ Post::t('pwhash'), $res['uid']);
+ XDB::query('DELETE FROM register_pending_xnet
+ WHERE uid = {?}',
+ $res['uid']);
+ XDB::commit();
+
+ S::logger($res['uid'])->log('passwd', '');
+
+ // Try to start a session (so the user don't have to log in); we will use
+ // the password available in Post:: to authenticate the user.
+ Post::kill('wait');
+ Platal::session()->startAvailableAuth();
+
+ $page->changeTpl('xnet/register.success.tpl');
+ $page->assign('email', $res['email']);
+ } else {
+ $page->changeTpl('platal/password.tpl');
+ $page->assign('xnet', true);
+ $page->assign('hruid', $res['hruid']);
+ $page->assign('do_auth', 1);