- function handler_login_ext($page)
- {
- if (!S::logged()) {
- $page->changeTpl('xnet/login.tpl');
- } else {
- pl_redirect('');
- }
- }
-
- 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
- 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::query('UPDATE accounts
- SET password = {?}, state = \'active\'
- WHERE uid = {?} AND state = \'pending\' AND type = \'xnet\'',
- Post::t('pwhash'), $res['uid']);
- XDB::query('DELETE FROM register_pending_xnet
- WHERE uid = {?}',
- $res['uid']);
-
- 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('hruid', $res['hruid']);
- } else {
- $page->changeTpl('platal/password.tpl');
- $page->assign('xnet', true);
- $page->assign('hruid', $res['hruid']);
- $page->assign('do_auth', true);
- }
- }
-