Passed
Push — master ( 9c2eb6...7fc67e )
by Michael
05:54
created

activate.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * Extended User Profile
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 *
14
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
15
 * @license             GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @package             profile
17
 * @since               2.3.0
18
 * @author              Jan Pedersen
19
 * @author              Taiwen Jiang <[email protected]>
20
 */
21
$xoopsOption['pagetype'] = 'user';
22
require __DIR__ . '/header.php';
23
include $GLOBALS['xoops']->path('header.php');
24
if (!empty($_GET['id']) && !empty($_GET['actkey'])) {
25
    $id     = (int)$_GET['id'];
26
    $actkey = trim($_GET['actkey']);
27
    if (empty($id)) {
28
        redirect_header(XOOPS_URL, 1, '');
29
    }
30
    /* @var XoopsMemberHandler $memberHandler */
31
    $memberHandler = xoops_getHandler('member');
32
    $thisuser      = $memberHandler->getUser($id);
33
    if (!is_object($thisuser)) {
34
        redirect_header(XOOPS_URL, 1, '');
35
    }
36
    if ($thisuser->getVar('actkey') != $actkey) {
37
        redirect_header(XOOPS_URL . '/', 5, _US_ACTKEYNOT);
38
    } elseif ($thisuser->getVar('level') > 0) {
39
            redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/index.php', 5, _US_ACONTACT, false);
40
        } elseif (false !== $memberHandler->activateUser($thisuser)) {
41
                $xoopsPreload = XoopsPreload::getInstance();
42
                $xoopsPreload->triggerEvent('core.behavior.user.activate', $thisuser);
43
                /* @var XoopsConfigHandler $configHandler */
44
                $configHandler              = xoops_getHandler('config');
45
                $GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(XOOPS_CONF_USER);
46
                if (2 == $GLOBALS['xoopsConfigUser']['activation_type']) {
47
                    $myts        = \MyTextSanitizer::getInstance();
48
                    $xoopsMailer = xoops_getMailer();
49
                    $xoopsMailer->useMail();
50
                    $xoopsMailer->setTemplate('activated.tpl');
51
                    $xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']);
52
                    $xoopsMailer->assign('ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']);
53
                    $xoopsMailer->assign('SITEURL', XOOPS_URL . '/');
54
                    $xoopsMailer->setToUsers($thisuser);
55
                    $xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']);
56
                    $xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']);
57
                    $xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT, $GLOBALS['xoopsConfig']['sitename']));
58
                    include $GLOBALS['xoops']->path('header.php');
59
                    if ($xoopsMailer->send()) {
60
                        printf(_US_ACTVMAILOK, $thisuser->getVar('uname'));
0 ignored issues
show
It seems like $thisuser->getVar('uname') can also be of type array and array; however, parameter $values of printf() does only seem to accept double|integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

60
                        printf(_US_ACTVMAILOK, /** @scrutinizer ignore-type */ $thisuser->getVar('uname'));
Loading history...
61
                    } else {
62
                        printf(_US_ACTVMAILNG, $thisuser->getVar('uname'));
63
                    }
64
                    require __DIR__ . '/footer.php';
65
                } else {
66
                    redirect_header(XOOPS_URL . '/user.php', 5, _US_ACTLOGIN, false);
67
                }
68
            } else {
69
                redirect_header(XOOPS_URL . '/index.php', 5, 'Activation failed!');
70
            }
71
72
    // Not implemented yet: re-send activiation code
73
} elseif (!empty($_REQUEST['email']) && 0 != $xoopsConfigUser['activation_type']) {
74
    $myts = \MyTextSanitizer::getInstance();
75
    /* @var XoopsMemberHandler $memberHandler */
76
    $memberHandler = xoops_getHandler('member');
77
    $getuser       = $memberHandler->getUsers(new Criteria('email', $myts->addSlashes(trim($_REQUEST['email']))));
78
    if (0 == count($getuser)) {
79
        redirect_header(XOOPS_URL, 2, _US_SORRYNOTFOUND);
80
    }
81
    if ($getuser[0]->isActive()) {
82
        redirect_header(XOOPS_URL, 2, sprintf(_US_USERALREADYACTIVE, $getuser[0]->getVar('email')));
83
    }
84
    $xoopsMailer = xoops_getMailer();
85
    $xoopsMailer->useMail();
86
    $xoopsMailer->setTemplate('register.tpl');
87
    $xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']);
88
    $xoopsMailer->assign('ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']);
89
    $xoopsMailer->assign('SITEURL', XOOPS_URL . '/');
90
    $xoopsMailer->setToUsers($getuser[0]);
91
    $xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']);
92
    $xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']);
93
    $xoopsMailer->setSubject(sprintf(_US_USERKEYFOR, $getuser[0]->getVar('uname')));
94
    if ($xoopsMailer->send()) {
95
        echo _US_YOURREGISTERED;
96
    } else {
97
        echo _US_YOURREGMAILNG;
98
    }
99
} else {
100
    require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
101
    $form = new \XoopsThemeForm('', 'form', 'activate.php');
102
    $form->addElement(new \XoopsFormText(_US_EMAIL, 'email', 25, 255));
103
    $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
104
    $form->display();
105
}
106
$xoBreadcrumbs[] = ['title' => _MD_SUICO_REGISTER];
107
require __DIR__ . '/footer.php';
108