Passed
Push — master ( 6d3e95...4ad186 )
by Goffy
03:09
created

admin/feedback.php (6 issues)

Labels
Severity
1
<?php
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 or later (http://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;
0 ignored issues
show
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
24
include __DIR__ . '/header.php';
25
26
$adminObject = \Xmf\Module\Admin::getInstance();
0 ignored issues
show
The type Xmf\Module\Admin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
28
$feedback = new \XoopsModules\Wggithub\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);
0 ignored issues
show
The function xoops_loadLanguage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

34
/** @scrutinizer ignore-call */ 
35
\xoops_loadLanguage('feedback', $moduleDirName);
Loading history...
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;
0 ignored issues
show
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
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()));
0 ignored issues
show
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

51
            /** @scrutinizer ignore-call */ \redirect_header('index.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
Loading history...
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();
0 ignored issues
show
The function xoops_getMailer was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

70
        $xoopsMailer = /** @scrutinizer ignore-call */ xoops_getMailer();
Loading history...
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(true);
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