|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
You may not change or alter any portion of this comment or credits |
|
5
|
|
|
of supporting developers from this source code or any supporting source code |
|
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
|
|
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
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Feedback plugin for xoops modules |
|
15
|
|
|
* |
|
16
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
17
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
18
|
|
|
* @author Michael Beck <[email protected]> |
|
19
|
|
|
* @author Wedega - Email:<[email protected]> |
|
20
|
|
|
* @author Fernando Santos (topet05) <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
use Xmf\Request; |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
require __DIR__ . '/header.php'; |
|
26
|
|
|
|
|
27
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
|
28
|
|
|
|
|
29
|
|
|
$feedback = new \XoopsModules\Wgevents\Common\ModuleFeedback(); |
|
30
|
|
|
|
|
31
|
|
|
// It recovered the value of argument op in URL$ |
|
32
|
|
|
$op = Request::getString('op', 'list'); |
|
33
|
|
|
$moduleDirName = $GLOBALS['xoopsModule']->getVar('dirname'); |
|
34
|
|
|
$moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
35
|
|
|
\xoops_loadLanguage('feedback', $moduleDirName); |
|
36
|
|
|
|
|
37
|
|
|
switch ($op) { |
|
38
|
|
|
case 'list': |
|
39
|
|
|
default: |
|
40
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php')); |
|
41
|
|
|
$feedback->name = $GLOBALS['xoopsUser']->getVar('name'); |
|
42
|
|
|
$feedback->email = $GLOBALS['xoopsUser']->getVar('email'); |
|
43
|
|
|
$feedback->site = \XOOPS_URL; |
|
44
|
|
|
$form = $feedback->getFormFeedback(); |
|
45
|
|
|
$form->display(); |
|
46
|
|
|
break; |
|
47
|
|
|
case 'send': |
|
48
|
|
|
// Security Check |
|
49
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
|
50
|
|
|
\redirect_header('index.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php')); |
|
54
|
|
|
|
|
55
|
|
|
$your_name = Request::getString('your_name'); |
|
56
|
|
|
$your_site = Request::getString('your_site'); |
|
57
|
|
|
$your_mail = Request::getString('your_mail'); |
|
58
|
|
|
$fb_type = Request::getString('fb_type'); |
|
59
|
|
|
$fb_content = Request::getText('fb_content'); |
|
60
|
|
|
$fb_content = \str_replace(["\r\n", "\n", "\r"], '<br>', $fb_content); //clean line break from dhtmltextarea |
|
61
|
|
|
|
|
62
|
|
|
$title = \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_FOR') . $GLOBALS['xoopsModule']->getVar('dirname'); |
|
63
|
|
|
$body = \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME') . ': ' . $your_name . '<br>'; |
|
64
|
|
|
$body .= \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL') . ': ' . $your_mail . '<br>'; |
|
65
|
|
|
$body .= \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE') . ': ' . $your_site . '<br>'; |
|
66
|
|
|
$body .= \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE') . ': ' . $fb_type . '<br><br>'; |
|
67
|
|
|
$body .= \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT') . ':<br>'; |
|
68
|
|
|
$body .= $fb_content; |
|
69
|
|
|
$xoopsMailer = xoops_getMailer(); |
|
70
|
|
|
$xoopsMailer->useMail(); |
|
71
|
|
|
$xoopsMailer->setToEmails($GLOBALS['xoopsModule']->getInfo('author_mail')); |
|
72
|
|
|
$xoopsMailer->setFromEmail($your_mail); |
|
73
|
|
|
$xoopsMailer->setFromName($your_name); |
|
74
|
|
|
$xoopsMailer->setSubject($title); |
|
75
|
|
|
$xoopsMailer->multimailer->isHTML(); |
|
76
|
|
|
$xoopsMailer->setBody($body); |
|
77
|
|
|
$ret = $xoopsMailer->send(); |
|
78
|
|
|
if ($ret) { |
|
79
|
|
|
\redirect_header('index.php', 3, \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_SUCCESS')); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
// show form with content again |
|
83
|
|
|
$feedback->name = $your_name; |
|
84
|
|
|
$feedback->email = $your_mail; |
|
85
|
|
|
$feedback->site = $your_site; |
|
86
|
|
|
$feedback->type = $fb_type; |
|
87
|
|
|
$feedback->content = $fb_content; |
|
88
|
|
|
echo '<div style="text-align:center;width: 80%; padding: 10px; border: 2px solid #ff0000; color: #ff0000; margin-right:auto;margin-left:auto;"> |
|
89
|
|
|
<h3>' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_ERROR') . '</h3> |
|
90
|
|
|
</div>'; |
|
91
|
|
|
$form = $feedback->getFormFeedback(); |
|
92
|
|
|
$form->display(); |
|
93
|
|
|
|
|
94
|
|
|
break; |
|
95
|
|
|
} |
|
96
|
|
|
require __DIR__ . '/footer.php'; |
|
97
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: