1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @category Module |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use Xmf\Module\Admin; |
20
|
|
|
use Xmf\Request; |
|
|
|
|
21
|
|
|
use XoopsModules\Suico\{ |
22
|
|
|
Common\ModuleFeedback, |
23
|
|
|
Helper, |
24
|
|
|
Utility |
25
|
|
|
}; |
26
|
|
|
/** @var Helper $helper */ |
27
|
|
|
/** @var Utility $utility */ |
28
|
|
|
/** @var Admin $adminObject */ |
29
|
|
|
require_once __DIR__ . '/admin_header.php'; |
30
|
|
|
$adminObject = Admin::getInstance(); |
31
|
|
|
$feedback = new ModuleFeedback(); |
32
|
|
|
// It recovered the value of argument op in URL$ |
33
|
|
|
$op = Request::getString('op', 'list'); |
34
|
|
|
$moduleDirName = $GLOBALS['xoopsModule']->getVar('dirname'); |
35
|
|
|
$moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
36
|
|
|
xoops_loadLanguage('feedback', $moduleDirName); |
37
|
|
|
xoops_cp_header(); |
38
|
|
|
switch ($op) { |
39
|
|
|
case 'list': |
40
|
|
|
default: |
41
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php')); |
42
|
|
|
$feedback->name = $GLOBALS['xoopsUser']->getVar('name'); |
43
|
|
|
$feedback->email = $GLOBALS['xoopsUser']->getVar('email'); |
44
|
|
|
$feedback->site = XOOPS_URL; |
45
|
|
|
$form = $feedback->getFormFeedback(); |
46
|
|
|
echo $form->render(); |
47
|
|
|
break; |
48
|
|
|
case 'send': |
49
|
|
|
// Security Check |
50
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
51
|
|
|
redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
52
|
|
|
} |
53
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php')); |
54
|
|
|
$your_name = Request::getString('your_name', ''); |
55
|
|
|
$your_site = Request::getString('your_site', ''); |
56
|
|
|
$your_mail = Request::getString('your_mail', ''); |
57
|
|
|
$fb_type = Request::getString('fb_type', ''); |
58
|
|
|
$fb_content = Request::getText('fb_content', ''); |
59
|
|
|
$fb_content = str_replace( |
60
|
|
|
['', '', ''], |
61
|
|
|
'<br>', |
62
|
|
|
$fb_content |
63
|
|
|
); //clean line break from dhtmltextarea |
64
|
|
|
$title = constant( |
65
|
|
|
'CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_FOR' |
66
|
|
|
) . $GLOBALS['xoopsModule']->getVar( |
67
|
|
|
'dirname' |
68
|
|
|
); |
69
|
|
|
$body = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME') . ': ' . $your_name . '<br>'; |
70
|
|
|
$body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL') . ': ' . $your_mail . '<br>'; |
71
|
|
|
$body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE') . ': ' . $your_site . '<br>'; |
72
|
|
|
$body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE') . ': ' . $fb_type . '<br><br>'; |
73
|
|
|
$body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT') . ':<br>'; |
74
|
|
|
$body .= $fb_content; |
75
|
|
|
$xoopsMailer = xoops_getMailer(); |
76
|
|
|
$xoopsMailer->useMail(); |
77
|
|
|
$xoopsMailer->setToEmails($GLOBALS['xoopsModule']->getInfo('author_mail')); |
78
|
|
|
$xoopsMailer->setFromEmail($your_mail); |
79
|
|
|
$xoopsMailer->setFromName($your_name); |
80
|
|
|
$xoopsMailer->setSubject($title); |
81
|
|
|
$xoopsMailer->multimailer->isHTML(true); |
82
|
|
|
$xoopsMailer->setBody($body); |
83
|
|
|
$ret = $xoopsMailer->send(); |
84
|
|
|
if ($ret) { |
85
|
|
|
redirect_header('index.php', 3, constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_SUCCESS')); |
86
|
|
|
} |
87
|
|
|
// show form with content again |
88
|
|
|
$feedback->name = $your_name; |
89
|
|
|
$feedback->email = $your_mail; |
90
|
|
|
$feedback->site = $your_site; |
91
|
|
|
$feedback->type = $fb_type; |
92
|
|
|
$feedback->content = $fb_content; |
93
|
|
|
echo '<div align="center" style="width: 80%; padding: 10px; border: 2px solid #ff0000; color: #ff0000; margin-right:auto;margin-left:auto;"> |
94
|
|
|
<h3>' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_ERROR') . '</h3> |
95
|
|
|
</div>'; |
96
|
|
|
$form = $feedback->getFormFeedback(); |
97
|
|
|
echo $form->render(); |
98
|
|
|
break; |
99
|
|
|
} |
100
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
101
|
|
|
|
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: