1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* Extended User Profile |
4
|
|
|
* |
5
|
|
|
* You may not change or alter any portion of this comment or credits |
6
|
|
|
* of supporting developers from this source code or any supporting source code |
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
8
|
|
|
* This program is distributed in the hope that it will be useful, |
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
* |
12
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
13
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
14
|
|
|
* @since 2.3.0 |
15
|
|
|
* @author Jan Pedersen |
16
|
|
|
* @author Taiwen Jiang <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
$xoopsOption['pagetype'] = 'user'; |
19
|
|
|
require __DIR__ . '/header.php'; |
20
|
|
|
include $GLOBALS['xoops']->path('header.php'); |
21
|
|
|
if (!empty($_GET['id']) && !empty($_GET['actkey'])) { |
22
|
|
|
$id = (int)$_GET['id']; |
23
|
|
|
$actkey = trim($_GET['actkey']); |
24
|
|
|
if (empty($id)) { |
25
|
|
|
redirect_header(XOOPS_URL, 1, ''); |
26
|
|
|
} |
27
|
|
|
/** @var XoopsMemberHandler $memberHandler */ |
28
|
|
|
$memberHandler = xoops_getHandler('member'); |
29
|
|
|
$thisuser = $memberHandler->getUser($id); |
30
|
|
|
if (!is_object($thisuser)) { |
31
|
|
|
redirect_header(XOOPS_URL, 1, ''); |
32
|
|
|
} |
33
|
|
|
if ($thisuser->getVar('actkey') != $actkey) { |
34
|
|
|
redirect_header(XOOPS_URL . '/', 5, _US_ACTKEYNOT); |
35
|
|
|
} elseif ($thisuser->getVar('level') > 0) { |
36
|
|
|
redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/index.php', 5, _US_ACONTACT, false); |
37
|
|
|
} elseif (false !== $memberHandler->activateUser($thisuser)) { |
38
|
|
|
$xoopsPreload = XoopsPreload::getInstance(); |
39
|
|
|
$xoopsPreload->triggerEvent('core.behavior.user.activate', $thisuser); |
40
|
|
|
/** @var XoopsConfigHandler $configHandler */ |
41
|
|
|
$configHandler = xoops_getHandler('config'); |
42
|
|
|
$GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(XOOPS_CONF_USER); |
43
|
|
|
if (2 == $GLOBALS['xoopsConfigUser']['activation_type']) { |
44
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
45
|
|
|
$xoopsMailer = xoops_getMailer(); |
46
|
|
|
$xoopsMailer->useMail(); |
47
|
|
|
$xoopsMailer->setTemplate('activated.tpl'); |
48
|
|
|
$xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']); |
49
|
|
|
$xoopsMailer->assign('ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']); |
50
|
|
|
$xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
51
|
|
|
$xoopsMailer->setToUsers($thisuser); |
52
|
|
|
$xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']); |
53
|
|
|
$xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']); |
54
|
|
|
$xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT, $GLOBALS['xoopsConfig']['sitename'])); |
55
|
|
|
include $GLOBALS['xoops']->path('header.php'); |
56
|
|
|
if ($xoopsMailer->send()) { |
57
|
|
|
printf(_US_ACTVMAILOK, $thisuser->getVar('uname')); |
|
|
|
|
58
|
|
|
} else { |
59
|
|
|
printf(_US_ACTVMAILNG, $thisuser->getVar('uname')); |
60
|
|
|
} |
61
|
|
|
require __DIR__ . '/footer.php'; |
62
|
|
|
} else { |
63
|
|
|
redirect_header(XOOPS_URL . '/user.php', 5, _US_ACTLOGIN, false); |
64
|
|
|
} |
65
|
|
|
} else { |
66
|
|
|
redirect_header(XOOPS_URL . '/index.php', 5, 'Activation failed!'); |
67
|
|
|
} |
68
|
|
|
// Not implemented yet: re-send activiation code |
69
|
|
|
} elseif (!empty($_REQUEST['email']) && 0 != $xoopsConfigUser['activation_type']) { |
70
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
71
|
|
|
/** @var XoopsMemberHandler $memberHandler */ |
72
|
|
|
$memberHandler = xoops_getHandler('member'); |
73
|
|
|
$getuser = $memberHandler->getUsers(new Criteria('email', $GLOBALS['xoopsDB']->escape(trim($_REQUEST['email'])))); |
74
|
|
|
if (0 == count($getuser)) { |
75
|
|
|
redirect_header(XOOPS_URL, 2, _US_SORRYNOTFOUND); |
76
|
|
|
} |
77
|
|
|
if ($getuser[0]->isActive()) { |
78
|
|
|
redirect_header(XOOPS_URL, 2, sprintf(_US_USERALREADYACTIVE, $getuser[0]->getVar('email'))); |
79
|
|
|
} |
80
|
|
|
$xoopsMailer = xoops_getMailer(); |
81
|
|
|
$xoopsMailer->useMail(); |
82
|
|
|
$xoopsMailer->setTemplate('register.tpl'); |
83
|
|
|
$xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']); |
84
|
|
|
$xoopsMailer->assign('ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']); |
85
|
|
|
$xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
86
|
|
|
$xoopsMailer->setToUsers($getuser[0]); |
87
|
|
|
$xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']); |
88
|
|
|
$xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']); |
89
|
|
|
$xoopsMailer->setSubject(sprintf(_US_USERKEYFOR, $getuser[0]->getVar('uname'))); |
90
|
|
|
if ($xoopsMailer->send()) { |
91
|
|
|
echo _US_YOURREGISTERED; |
92
|
|
|
} else { |
93
|
|
|
echo _US_YOURREGMAILNG; |
94
|
|
|
} |
95
|
|
|
} else { |
96
|
|
|
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
97
|
|
|
$form = new \XoopsThemeForm('', 'form', 'activate.php'); |
98
|
|
|
$form->addElement(new \XoopsFormText(_US_EMAIL, 'email', 25, 255)); |
99
|
|
|
$form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
100
|
|
|
$form->display(); |
101
|
|
|
} |
102
|
|
|
$xoBreadcrumbs[] = ['title' => _MD_SUICO_REGISTER]; |
103
|
|
|
require __DIR__ . '/footer.php'; |
104
|
|
|
|