These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | * ------------------------------------------------------------------------ |
||
4 | * XOOPS - PHP Content Management System |
||
5 | * Copyright (c) 2000 XOOPS.org |
||
6 | * <http://www.xoops.org/> |
||
7 | * ------------------------------------------------------------------------ |
||
8 | * This program is free software; you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU General Public License as published by |
||
10 | * the Free Software Foundation; either version 2 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * You may not change or alter any portion of this comment or credits |
||
14 | * of supporting developers from this source code or any supporting |
||
15 | * source code which is considered copyrighted (c) material of the |
||
16 | * original comment or credit authors. |
||
17 | * |
||
18 | * This program is distributed in the hope that it will be useful, |
||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
21 | * GNU General Public License for more details. |
||
22 | * |
||
23 | * You should have received a copy of the GNU General Public License |
||
24 | * along with this program; if not, write to the Free Software |
||
25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
26 | * ------------------------------------------------------------------------- |
||
27 | * Author: Raul Recio (AKA UNFOR) |
||
28 | * Project: The XOOPS Project |
||
29 | * ------------------------------------------------------------------------- |
||
30 | */ |
||
31 | /** |
||
32 | * XoopsPartners - a partner affiliation links module |
||
33 | * |
||
34 | * @category Module |
||
35 | * @package xoopspartners |
||
36 | * @subpackage front |
||
37 | * @author Raul Recio (aka UNFOR) |
||
38 | * @author XOOPS Module Development Team |
||
39 | * @copyright {@link http://xoops.org 2001-2016 XOOPS Project} |
||
40 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
||
41 | * @link http://xoops.org XOOPS |
||
42 | */ |
||
43 | |||
44 | include __DIR__ . '/header.php'; |
||
45 | /** @var string $xoopsOption */ |
||
46 | $xoopsOption['template_main'] = 'xoopspartners_join.tpl'; |
||
47 | include $GLOBALS['xoops']->path('/header.php'); |
||
48 | $myts = MyTextSanitizer::getInstance(); |
||
49 | |||
50 | $op = XoopsRequest::getCmd('op', '', 'POST'); |
||
51 | |||
52 | if (!$GLOBALS['xoopsUser'] instanceof XoopsUser) { |
||
0 ignored issues
–
show
|
|||
53 | redirect_header('index.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _NOPERM); |
||
54 | } |
||
55 | |||
56 | if ('sendMail' === $op) { |
||
57 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
58 | redirect_header('index.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _MD_XPARTNERS_ERROR1 . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
||
59 | } |
||
60 | //Changed - don't extract $_POST vars directly into var table space |
||
61 | //extract($_POST); |
||
62 | extract($_POST, EXTR_PREFIX_ALL, 'unsafe'); |
||
63 | if (empty($unsafe_title) || empty($unsafe_description) || empty($unsafe_url) || $unsafe_url === 'http://') { |
||
64 | $GLOBALS['xoopsTpl']->assign(array( |
||
65 | 'content4join' => _MD_XPARTNERS_ERROR1, |
||
66 | 'lang_main_partner' => _MD_XPARTNERS_PARTNERS, |
||
67 | 'sitename' => $GLOBALS['xoopsConfig']['sitename'] |
||
68 | )); |
||
69 | // $xoopsContentsTpl = 'xoopspartners_join.tpl'; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
70 | include_once __DIR__ . '/footer.php'; |
||
71 | exit(); |
||
72 | } |
||
73 | include $GLOBALS['xoops']->path('/class/xoopsmailer.php'); |
||
74 | $url = formatURL($myts->htmlSpecialChars($unsafe_url)); |
||
75 | $title = $myts->htmlSpecialChars($unsafe_title); |
||
76 | $description = $myts->htmlSpecialChars($unsafe_description); |
||
77 | $image = formatURL($myts->htmlSpecialChars($unsafe_image)); |
||
78 | $image = xoops_trim($image); |
||
79 | $image = (('http://' === $image) || ('https://' === $image)) ? '' : $image; |
||
80 | if (!empty($image)) { |
||
81 | $allowed_mimetypes = array( |
||
82 | 'gif' => 'image/gif', |
||
83 | 'jpg' => 'image/jpeg', |
||
84 | 'pjpe' => 'image/pjpeg', //IE7 |
||
85 | 'png' => 'image/png', |
||
86 | 'xpng' => 'image/x-png', //IE7 |
||
87 | // 'bmp' => 'image/bmp', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
88 | // 'tiff' => 'image/tiff', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
89 | // 'tif' => 'image/tif', |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
90 | ); |
||
91 | $maxfilesize = ((int)$GLOBALS['xoopsModule']->getInfo('maxuploadsize') > 0) ? $GLOBALS['xoopsModule']->getInfo('maxuploadsize') : XoopspartnersConstants::DEFAULT_UPLOAD_SIZE; |
||
92 | $maxfilewidth = ((int)$GLOBALS['xoopsModule']->getInfo('maxwidth') > 0) ? $GLOBALS['xoopsModule']->getInfo('maxwidth') : XoopspartnersConstants::DEFAULT_MAX_WIDTH; |
||
93 | $maxfileheight = ((int)$GLOBALS['xoopsModule']->getInfo('maxheight') > 0) ? $GLOBALS['xoopsModule']->getInfo('maxheight') : XoopspartnersConstants::DEFAULT_MAX_HEIGHT; |
||
94 | if (preg_match('^http:\/\/|https:\/\/[^\s]', $image)) { |
||
95 | // image is from external source |
||
96 | XoopsLoad::load('xoopsmediauploader'); |
||
97 | $uploader = new XoopsMediaUploader($GLOBALS['xoops']->path('/uploads/xoopspartners'), $allowed_mimetypes, $maxfilesize); |
||
98 | if ($uploader->fetchMedia($image)) { |
||
99 | if ($uploader->upload()) { |
||
100 | // echo "<h4>File uploaded successfully!</h4>\n"; |
||
101 | $image = $uploader->getSavedFileName(); // get file name to save in db |
||
102 | // echo 'Full path: ' . $uploader->getSavedDestination(); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
54% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
103 | } |
||
104 | } |
||
105 | } |
||
106 | |||
107 | $imageInfo = @getimagesize($image); |
||
108 | $uploadErrs = ($uploader instanceof XoopsMediaUploader) ? $uploader->getErrors() : ''; |
||
0 ignored issues
–
show
The class
XoopsMediaUploader does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
109 | if (false == $imageInfo || !empty($uploadErrs)) { // could not find image |
||
110 | $GLOBALS['xoopsTpl']->assign(array( |
||
111 | 'content4join' => sprintf(_MD_XPARTNERS_ERROR3, $image) . '<br>' . $uploader->getErrors(), |
||
112 | 'lang_main_partner' => _MD_XPARTNERS_PARTNERS, |
||
113 | 'sitename' => $GLOBALS['xoopsConfig']['sitename'] |
||
114 | )); |
||
115 | // $xoopsContentsTpl = 'xoopspartners_join.tpl'; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
116 | include_once __DIR__ . '/footer.php'; |
||
117 | exit(); |
||
118 | } |
||
119 | } |
||
120 | $xoopsMailer =& xoops_getMailer(); |
||
121 | $xoopsMailer->useMail(); |
||
122 | $xoopsMailer->setTemplateDir($GLOBALS['xoops']->path('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . "/language/{$GLOBALS['xoopsConfig']['language']}/mail_template/")); |
||
123 | $xoopsMailer->setTemplate('join.tpl'); |
||
124 | $xoopsMailer->assign(array( |
||
125 | 'SITENAME' => $GLOBALS['xoopsConfig']['sitename'], |
||
126 | 'SITEURL' => $GLOBALS['xoops']->url('www'), |
||
127 | 'IP' => $_SERVER['REMOTE_ADDR'], |
||
128 | 'URL' => $url, |
||
129 | 'IMAGE' => $image, |
||
130 | 'TITLE' => $title, |
||
131 | 'DESCRIPTION' => $description, |
||
132 | 'USER' => $GLOBALS['xoopsUser']->getVar('uname'), |
||
133 | 'MODULENAME' => $GLOBALS['xoopsModule']->getVar('dirname') |
||
134 | )); |
||
135 | $xoopsMailer->setToEmails($GLOBALS['xoopsConfig']['adminmail']); |
||
136 | $xoopsMailer->setFromEmail($GLOBALS['xoopsUser']->getVar('email')); |
||
137 | $xoopsMailer->setFromName($GLOBALS['xoopsUser']->getVar('uname')); |
||
138 | $xoopsMailer->setSubject(sprintf(_MD_XPARTNERS_NEWPARTNER, $GLOBALS['xoopsConfig']['sitename'])); |
||
139 | if (!$xoopsMailer->send()) { |
||
140 | $GLOBALS['xoopsTpl']->assign(array( |
||
141 | 'content4join' => '<br>' . $xoopsMailer->getErrors() . _MD_XPARTNERS_GOBACK, |
||
142 | 'lang_main_partner' => _MD_XPARTNERS_PARTNERS, |
||
143 | 'lang_join' => _MD_XPARTNERS_JOIN, |
||
144 | 'sitename' => $GLOBALS['xoopsConfig']['sitename'] |
||
145 | )); |
||
146 | } else { |
||
147 | $GLOBALS['xoopsTpl']->assign(array( |
||
148 | 'content4join' => '<br>' . _MD_XPARTNERS_SENDMAIL, |
||
149 | 'lang_main_partner' => _MD_XPARTNERS_PARTNERS, |
||
150 | 'lang_join' => _MD_XPARTNERS_JOIN, |
||
151 | 'sitename' => $GLOBALS['xoopsConfig']['sitename'] |
||
152 | )); |
||
153 | } |
||
154 | // $xoopsContentsTpl = 'xoopspartners_join.tpl'; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
155 | } else { |
||
156 | include $GLOBALS['xoops']->path('/class/xoopsformloader.php'); |
||
157 | $form = new XoopsThemeForm('', 'joinform', 'join.php', 'post', true); |
||
158 | $form->setExtra('enctype="multipart/form-data"'); |
||
159 | $titlePartner = new XoopsFormText(_MD_XPARTNERS_TITLE, 'title', 100, 150); |
||
160 | $imagePartner = new XoopsFormText(_MD_XPARTNERS_IMAGE, 'image', 100, 150, 'http://'); |
||
161 | $urlPartner = new XoopsFormText(_MD_XPARTNERS_URL, 'url', 100, 150, 'http://'); |
||
162 | $descriptionPartner = new XoopsFormTextArea(_MD_XPARTNERS_DESCRIPTION, 'description', '', 7, 50); |
||
163 | $op_hidden = new XoopsFormHidden('op', 'sendMail'); |
||
164 | $submitButton = new XoopsFormButton('', 'dbsubmit', _MD_XPARTNERS_SEND, 'submit'); |
||
165 | $form->addElement($titlePartner, true); |
||
166 | $form->addElement($imagePartner); |
||
167 | $form->addElement($urlPartner, true); |
||
168 | $form->addElement($descriptionPartner, true); |
||
169 | $form->addElement($op_hidden); |
||
170 | $form->addElement($submitButton); |
||
171 | $content = $form->render(); |
||
172 | $GLOBALS['xoopsTpl']->assign(array( |
||
173 | 'content4join' => $content, |
||
174 | 'lang_main_partner' => _MD_XPARTNERS_PARTNERS, |
||
175 | 'lang_join' => _MD_XPARTNERS_JOIN, |
||
176 | 'sitename' => $GLOBALS['xoopsConfig']['sitename'] |
||
177 | )); |
||
178 | } |
||
179 | |||
180 | include_once __DIR__ . '/footer.php'; |
||
181 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.