1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Extended User Profile |
5
|
|
|
* |
6
|
|
|
* You may not change or alter any portion of this comment or credits |
7
|
|
|
* of supporting developers from this source code or any supporting source code |
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
* This program is distributed in the hope that it will be useful, |
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12
|
|
|
* |
13
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
14
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @since 2.3.0 |
16
|
|
|
* @author Taiwen Jiang <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use Xmf\Request; |
|
|
|
|
20
|
|
|
use XoopsModules\Suico\IndexController; |
21
|
|
|
|
22
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'suico_email.tpl'; |
23
|
|
|
require __DIR__ . '/header.php'; |
24
|
|
|
/** |
25
|
|
|
* Fetching numbers of groups friends videos pictures etc... |
26
|
|
|
*/ |
27
|
|
|
$controller = new IndexController($xoopsDB, $xoopsUser, $xoopsModule); |
28
|
|
|
$nbSections = $controller->getNumbersSections(); |
29
|
|
|
/** @var XoopsConfigHandler $configHandler */ |
30
|
|
|
$configHandler = xoops_getHandler('config'); |
31
|
|
|
$GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(XOOPS_CONF_USER); |
32
|
|
|
if (!$GLOBALS['xoopsUser'] || 1 != $GLOBALS['xoopsConfigUser']['allow_chgmail']) { |
33
|
|
|
redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/', 2, _NOPERM); |
34
|
|
|
} |
35
|
|
|
if (isset($_POST['submit'], $_POST['passwd'])) { |
36
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
37
|
|
|
$pass = Request::getString('passwd', '', 'POST'); |
38
|
|
|
$email = Request::getString('newmail', '', 'POST'); |
39
|
|
|
$errors = []; |
40
|
|
|
if (!password_verify($oldpass, $GLOBALS['xoopsUser']->getVar('pass', 'n'))) { |
41
|
|
|
$errors[] = _MD_SUICO_WRONGPASSWORD; |
42
|
|
|
} |
43
|
|
|
if (!checkEmail($email)) { |
44
|
|
|
$errors[] = _US_INVALIDMAIL; |
45
|
|
|
} |
46
|
|
|
if ($errors) { |
47
|
|
|
$msg = implode('<br>', $errors); |
48
|
|
|
} else { |
49
|
|
|
//update password |
50
|
|
|
$GLOBALS['xoopsUser']->setVar('email', Request::getString('newmail', '', 'POST')); |
51
|
|
|
/** @var XoopsMemberHandler $memberHandler */ |
52
|
|
|
$memberHandler = xoops_getHandler('member'); |
53
|
|
|
if ($memberHandler->insertUser($GLOBALS['xoopsUser'])) { |
54
|
|
|
$msg = _MD_SUICO_EMAILCHANGED; |
55
|
|
|
//send email to new email address |
56
|
|
|
$xoopsMailer = xoops_getMailer(); |
57
|
|
|
$xoopsMailer->useMail(); |
58
|
|
|
$xoopsMailer->setTemplateDir($GLOBALS['xoopsModule']->getVar('dirname', 'n')); |
59
|
|
|
$xoopsMailer->setTemplate('emailchanged.tpl'); |
60
|
|
|
$xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']); |
61
|
|
|
$xoopsMailer->assign('ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']); |
62
|
|
|
$xoopsMailer->assign('SITEURL', XOOPS_URL . '/'); |
63
|
|
|
$xoopsMailer->assign('NEWEMAIL', $email); |
64
|
|
|
$xoopsMailer->setToEmails($email); |
65
|
|
|
$xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']); |
66
|
|
|
$xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']); |
67
|
|
|
$xoopsMailer->setSubject(sprintf(_MD_SUICO_NEWEMAIL, $GLOBALS['xoopsConfig']['sitename'])); |
68
|
|
|
$xoopsMailer->send(); |
69
|
|
|
} else { |
70
|
|
|
$msg = implode('<br>', $GLOBALS['xoopsUser']->getErrors()); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/index.php?uid=' . $GLOBALS['xoopsUser']->getVar('uid'), 2, $msg); |
74
|
|
|
} else { |
75
|
|
|
//show change password form |
76
|
|
|
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
77
|
|
|
$form = new \XoopsThemeForm(_MD_SUICO_CHANGEMAIL, 'emailform', $_SERVER['REQUEST_URI'], 'post', true); |
78
|
|
|
$form->addElement(new \XoopsFormPassword(_US_PASSWORD, 'passwd', 15, 50), true); |
79
|
|
|
$form->addElement(new \XoopsFormText(_MD_SUICO_NEWMAIL, 'newmail', 15, 50), true); |
80
|
|
|
$form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
81
|
|
|
$form->assign($GLOBALS['xoopsTpl']); |
82
|
|
|
} |
83
|
|
|
$xoopsOption['xoops_pagetitle'] = sprintf(_MD_SUICO_CHANGEMAIL, $xoopsModule->getVar('name'), $controller->nameOwner); |
|
|
|
|
84
|
|
|
require __DIR__ . '/footer.php'; |
85
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
86
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: