This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace XoopsModules\Xnewsletter; |
||
4 | |||
5 | /** |
||
6 | * **************************************************************************** |
||
7 | * - A Project by Developers TEAM For Xoops - ( https://xoops.org ) |
||
8 | * **************************************************************************** |
||
9 | * XNEWSLETTER - MODULE FOR XOOPS |
||
10 | * Copyright (c) 2007 - 2012 |
||
11 | * Goffy ( wedega.com ) |
||
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 | * @copyright Goffy ( wedega.com ) |
||
24 | * @license GNU General Public License 2.0 |
||
25 | * @package xnewsletter |
||
26 | * @author Goffy ( [email protected] ) |
||
27 | * |
||
28 | * **************************************************************************** |
||
29 | */ |
||
30 | |||
31 | //use XoopsModules\Xnewsletter; |
||
32 | |||
33 | require_once dirname(__DIR__) . '/include/common.php'; |
||
34 | |||
35 | /** |
||
36 | * Class Mailinglist |
||
37 | */ |
||
38 | class Mailinglist extends \XoopsObject |
||
39 | { |
||
40 | public $helper = null; |
||
41 | public $db; |
||
42 | |||
43 | //Constructor |
||
44 | |||
45 | public function __construct() |
||
46 | { |
||
47 | $this->helper = Helper::getInstance(); |
||
48 | $this->db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
49 | $this->initVar('mailinglist_id', XOBJ_DTYPE_INT, null, false); |
||
50 | $this->initVar('mailinglist_name', XOBJ_DTYPE_TXTBOX, null, false, 100); |
||
51 | $this->initVar('mailinglist_email', XOBJ_DTYPE_TXTBOX, null, false, 100); |
||
52 | $this->initVar('mailinglist_listname', XOBJ_DTYPE_TXTBOX, null, false, 100); |
||
53 | $this->initVar('mailinglist_subscribe', XOBJ_DTYPE_TXTBOX, null, false, 100); |
||
54 | $this->initVar('mailinglist_unsubscribe', XOBJ_DTYPE_TXTBOX, null, false, 100); |
||
55 | $this->initVar('mailinglist_submitter', XOBJ_DTYPE_INT, null, false); |
||
56 | $this->initVar('mailinglist_created', XOBJ_DTYPE_INT, time(), false); |
||
57 | $this->initVar('mailinglist_system', XOBJ_DTYPE_TXTBOX, null, false, 100); |
||
58 | $this->initVar('mailinglist_target', XOBJ_DTYPE_TXTBOX, null, false, 200); |
||
59 | $this->initVar('mailinglist_pwd', XOBJ_DTYPE_TXTBOX, null, false, 100); |
||
60 | $this->initVar('mailinglist_notifyowner', XOBJ_DTYPE_INT, null, false); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param bool $action |
||
65 | * |
||
66 | * @param int $system |
||
67 | * @return \XoopsThemeForm |
||
68 | */ |
||
69 | public function getForm($action = false, $system = 0) |
||
70 | { |
||
71 | global $xoopsDB; |
||
72 | |||
73 | if (false === $action) { |
||
74 | $action = $_SERVER['REQUEST_URI']; |
||
75 | } |
||
76 | |||
77 | $title = $this->isNew() ? sprintf(_AM_XNEWSLETTER_MAILINGLIST_ADD) : sprintf(_AM_XNEWSLETTER_MAILINGLIST_EDIT); |
||
78 | |||
79 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
80 | $form = new \XoopsThemeForm($title, 'xn_ml_form', $action, 'post', true); |
||
81 | $form->setExtra('enctype="multipart/form-data"'); |
||
82 | |||
83 | $form->addElement(new \XoopsFormHidden('mailinglist_system', $system)); |
||
84 | |||
85 | if ($system === _XNEWSLETTER_MAILINGLIST_TYPE_MAILMAN_VAL) { |
||
86 | $form->addElement(new \XoopsFormLabel(_AM_XNEWSLETTER_MAILINGLIST_SYSTEM, _AM_XNEWSLETTER_MAILINGLIST_SYSTEM_MAILMAN)); |
||
87 | |||
88 | $mailinglist_name = $this->isNew() ? 'myname' : $this->getVar('mailinglist_name'); |
||
89 | $form->addElement(new \XoopsFormText(_AM_XNEWSLETTER_MAILINGLIST_NAME, 'mailinglist_name', 50, 255, $mailinglist_name), true); |
||
90 | |||
91 | $mailinglist_listname = $this->isNew() ? 'nameofmylist' : $this->getVar('mailinglist_listname'); |
||
92 | $form->addElement(new \XoopsFormText(_AM_XNEWSLETTER_MAILINGLIST_LISTNAME, 'mailinglist_listname', 50, 255, $mailinglist_listname), true); |
||
93 | |||
94 | $form->addElement(new \XoopsFormHidden('mailinglist_email', '')); |
||
95 | $form->addElement(new \XoopsFormHidden('mailinglist_subscribe', '')); |
||
96 | $form->addElement(new \XoopsFormHidden('mailinglist_unsubscribe', '')); |
||
97 | |||
98 | $mailinglist_target = $this->isNew() ? 'https://lists.mydomain.com' : $this->getVar('mailinglist_target'); |
||
99 | $form->addElement(new \XoopsFormText( _AM_XNEWSLETTER_MAILINGLIST_TARGET, 'mailinglist_target', 50, 255, $mailinglist_target)); |
||
100 | |||
101 | $mailinglist_pwd = $this->isNew() ? '' : $this->getVar('mailinglist_pwd'); |
||
102 | $form->addElement(new \XoopsFormText( _AM_XNEWSLETTER_MAILINGLIST_PWD, 'mailinglist_pwd', 50, 255, $mailinglist_pwd)); |
||
103 | |||
104 | $mailinglist_notifyowner = $this->isNew() ? 1 : $this->getVar('mailinglist_notifyowner'); |
||
105 | $form->addElement(new \XoopsFormRadioYN(_AM_XNEWSLETTER_MAILINGLIST_NOTIFYOWNER, 'mailinglist_notifyowner', $mailinglist_notifyowner, _YES, _NO)); |
||
106 | } |
||
107 | if ($system === _XNEWSLETTER_MAILINGLIST_TYPE_MAJORDOMO_VAL) { |
||
108 | $form->addElement(new \XoopsFormLabel(_AM_XNEWSLETTER_MAILINGLIST_SYSTEM, _AM_XNEWSLETTER_MAILINGLIST_SYSTEM_MAJORDOMO)); |
||
109 | |||
110 | $mailinglist_name = $this->isNew() ? 'myname' : $this->getVar('mailinglist_name'); |
||
111 | $form->addElement(new \XoopsFormText(_AM_XNEWSLETTER_MAILINGLIST_NAME, 'mailinglist_name', 50, 255, $mailinglist_name), true); |
||
112 | |||
113 | $mailinglist_listname = $this->isNew() ? 'nameofmylist' : $this->getVar('mailinglist_listname'); |
||
114 | $form->addElement(new \XoopsFormText(_AM_XNEWSLETTER_MAILINGLIST_LISTNAME, 'mailinglist_listname', 50, 255, $mailinglist_listname), true); |
||
115 | |||
116 | $mailinglist_email = $this->isNew() ? '[email protected]' : $this->getVar('mailinglist_email'); |
||
117 | $form->addElement(new \XoopsFormText(_AM_XNEWSLETTER_MAILINGLIST_EMAIL_DESC, 'mailinglist_email', 50, 255, $mailinglist_email)); |
||
118 | |||
119 | $mailinglist_subscribe = $this->isNew() ? 'subscribe nameofmylist {email}' : $this->getVar('mailinglist_subscribe'); |
||
120 | $form->addElement(new \XoopsFormText(_AM_XNEWSLETTER_MAILINGLIST_SUBSCRIBE . "<br><span style='font-size:0,75em'>" . _AM_XNEWSLETTER_MAILINGLIST_SUBSCRIBE_DESC . '</span>', 'mailinglist_subscribe', 50, 255, $mailinglist_subscribe)); |
||
121 | |||
122 | $mailinglist_unsubscribe = $this->isNew() ? 'unsubscribe nameofmylist {email}' : $this->getVar('mailinglist_unsubscribe'); |
||
123 | $form->addElement(new \XoopsFormText(_AM_XNEWSLETTER_MAILINGLIST_UNSUBSCRIBE . "<br><span style='font-size:0,75em'>" . _AM_XNEWSLETTER_MAILINGLIST_SUBSCRIBE_DESC . '</span>', 'mailinglist_unsubscribe', 50, 255, $mailinglist_unsubscribe)); |
||
124 | |||
125 | $form->addElement(new \XoopsFormHidden('mailinglist_target', '')); |
||
126 | $form->addElement(new \XoopsFormHidden('mailinglist_pwd', '')); |
||
127 | $form->addElement(new \XoopsFormHidden('mailinglist_notifyowner', 0)); |
||
128 | } |
||
129 | |||
130 | $time = $this->isNew() ? time() : $this->getVar('mailinglist_created'); |
||
131 | $form->addElement(new \XoopsFormHidden('mailinglist_submitter', $GLOBALS['xoopsUser']->uid())); |
||
132 | $form->addElement(new \XoopsFormHidden('mailinglist_created', $time)); |
||
133 | |||
134 | $form->addElement(new \XoopsFormLabel(_AM_XNEWSLETTER_SUBMITTER, $GLOBALS['xoopsUser']->uname())); |
||
135 | $form->addElement(new \XoopsFormLabel(_AM_XNEWSLETTER_CREATED, formatTimestamp($time, 's'))); |
||
136 | |||
137 | $form->addElement(new \XoopsFormHidden('mailinglist_id', $this->getVar('mailinglist_id'))); |
||
138 | $form->addElement(new \XoopsFormHidden('op', 'save_mailinglist')); |
||
139 | $form->addElement(new \XoopsFormButtonTray('save', _SUBMIT, 'submit', '', false)); |
||
140 | |||
141 | return $form; |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * Get Values |
||
146 | * @param null $keys |
||
147 | * @param string|null $format |
||
148 | * @param int|null $maxDepth |
||
149 | * @return array |
||
150 | */ |
||
151 | public function getValuesMailinglist($keys = null, $format = null, $maxDepth = null) |
||
152 | { |
||
153 | $ret['id'] = $this->getVar('mailinglist_id'); |
||
0 ignored issues
–
show
|
|||
154 | $ret['name'] = $this->getVar('mailinglist_name'); |
||
155 | $ret['email'] = $this->getVar('mailinglist_email'); |
||
156 | $ret['listname'] = $this->getVar('mailinglist_listname'); |
||
157 | $ret['subscribe'] = $this->getVar('mailinglist_subscribe'); |
||
158 | $ret['unsubscribe'] = $this->getVar('mailinglist_unsubscribe'); |
||
159 | $ret['system'] = $this->getVar('mailinglist_system'); |
||
160 | switch ($this->getVar('mailinglist_system')) { |
||
161 | case _XNEWSLETTER_MAILINGLIST_TYPE_MAILMAN_VAL: |
||
162 | $ret['system_text'] = _AM_XNEWSLETTER_MAILINGLIST_SYSTEM_MAILMAN; |
||
163 | break; |
||
164 | case _XNEWSLETTER_MAILINGLIST_TYPE_MAJORDOMO_VAL: |
||
165 | $ret['system_text'] = _AM_XNEWSLETTER_MAILINGLIST_SYSTEM_MAJORDOMO; |
||
166 | break; |
||
167 | case _XNEWSLETTER_MAILINGLIST_TYPE_DEFAULT_VAL: |
||
168 | default: |
||
169 | $ret['system_text'] = _AM_XNEWSLETTER_MAILINGLIST_SYSTEM_DEFAULT; |
||
170 | break; |
||
171 | } |
||
172 | $ret['target'] = $this->getVar('mailinglist_target'); |
||
173 | $ret['pwd'] = $this->getVar('mailinglist_pwd'); |
||
174 | $ret['notifyowner'] = $this->getVar('mailinglist_notifyowner'); |
||
175 | $ret['notifyowner_text'] = $this->getVar('mailinglist_notifyowner') == 1 ? _YES : _NO; |
||
176 | $ret['created'] = formatTimestamp($this->getVar('mailinglist_created'), 's'); |
||
177 | $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('mailinglist_submitter')); |
||
178 | return $ret; |
||
179 | } |
||
180 | } |
||
181 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.