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
|
|
|
* Feedback plugin for xoops modules
|
14
|
|
|
*
|
15
|
|
|
* @copyright XOOPS Project (https://xoops.org)
|
16
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
|
17
|
|
|
* @author Michael Beck <[email protected]>
|
18
|
|
|
* @author Wedega - Email:<[email protected]>
|
19
|
|
|
* @author Fernando Santos (topet05) <[email protected]>
|
20
|
|
|
*/
|
21
|
|
|
|
22
|
|
|
use Xmf\Request;
|
|
|
|
|
23
|
|
|
|
24
|
|
|
require __DIR__ . '/header.php';
|
25
|
|
|
|
26
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance();
|
27
|
|
|
|
28
|
|
|
$feedback = new \XoopsModules\Wgfilemanager\Common\ModuleFeedback();
|
29
|
|
|
|
30
|
|
|
// It recovered the value of argument op in URL$
|
31
|
|
|
$op = Request::getString('op', 'list');
|
32
|
|
|
$moduleDirName = $GLOBALS['xoopsModule']->getVar('dirname');
|
33
|
|
|
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
|
34
|
|
|
\xoops_loadLanguage('feedback', $moduleDirName);
|
35
|
|
|
|
36
|
|
|
//xoops_cp_header();
|
37
|
|
|
|
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
|
|
|
$form->display();
|
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
|
|
|
|
54
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php'));
|
55
|
|
|
|
56
|
|
|
$your_name = Request::getString('your_name');
|
57
|
|
|
$your_site = Request::getString('your_site');
|
58
|
|
|
$your_mail = Request::getString('your_mail');
|
59
|
|
|
$fb_type = Request::getString('fb_type');
|
60
|
|
|
$fb_content = Request::getText('fb_content');
|
61
|
|
|
$fb_content = \str_replace(["\r\n", "\n", "\r"], '<br>', $fb_content); //clean line break from dhtmltextarea
|
62
|
|
|
|
63
|
|
|
$title = \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_FOR') . $GLOBALS['xoopsModule']->getVar('dirname');
|
64
|
|
|
$body = \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME') . ': ' . $your_name . '<br>';
|
65
|
|
|
$body .= \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL') . ': ' . $your_mail . '<br>';
|
66
|
|
|
$body .= \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE') . ': ' . $your_site . '<br>';
|
67
|
|
|
$body .= \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE') . ': ' . $fb_type . '<br><br>';
|
68
|
|
|
$body .= \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT') . ':<br>';
|
69
|
|
|
$body .= $fb_content;
|
70
|
|
|
$xoopsMailer = xoops_getMailer();
|
71
|
|
|
$xoopsMailer->useMail();
|
72
|
|
|
$xoopsMailer->setToEmails($GLOBALS['xoopsModule']->getInfo('author_mail'));
|
73
|
|
|
$xoopsMailer->setFromEmail($your_mail);
|
74
|
|
|
$xoopsMailer->setFromName($your_name);
|
75
|
|
|
$xoopsMailer->setSubject($title);
|
76
|
|
|
$xoopsMailer->multimailer->isHTML();
|
77
|
|
|
$xoopsMailer->setBody($body);
|
78
|
|
|
$ret = $xoopsMailer->send();
|
79
|
|
|
if ($ret) {
|
80
|
|
|
\redirect_header('index.php', 3, \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_SUCCESS'));
|
81
|
|
|
}
|
82
|
|
|
|
83
|
|
|
// show form with content again
|
84
|
|
|
$feedback->name = $your_name;
|
85
|
|
|
$feedback->email = $your_mail;
|
86
|
|
|
$feedback->site = $your_site;
|
87
|
|
|
$feedback->type = $fb_type;
|
88
|
|
|
$feedback->content = $fb_content;
|
89
|
|
|
echo '<div style="text-align:center;width: 80%; padding: 10px; border: 2px solid #ff0000; color: #ff0000; margin-right:auto;margin-left:auto;">
|
90
|
|
|
<h3>' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_ERROR') . '</h3>
|
91
|
|
|
</div>';
|
92
|
|
|
$form = $feedback->getFormFeedback();
|
93
|
|
|
$form->display();
|
94
|
|
|
|
95
|
|
|
break;
|
96
|
|
|
}
|
97
|
|
|
require __DIR__ . '/footer.php';
|
98
|
|
|
|
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: