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.
1 | <?php |
||
2 | |||
3 | namespace XoopsModules\Modulebuilder; |
||
4 | |||
5 | use XoopsModules\Modulebuilder; |
||
6 | |||
7 | /* |
||
8 | You may not change or alter any portion of this comment or credits |
||
9 | of supporting developers from this source code or any supporting source code |
||
10 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
11 | |||
12 | This program is distributed in the hope that it will be useful, |
||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
15 | */ |
||
16 | |||
17 | /** |
||
18 | * settings class. |
||
19 | * |
||
20 | * @copyright XOOPS Project (https://xoops.org) |
||
21 | * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
22 | * |
||
23 | * @since 2.5.7 |
||
24 | * |
||
25 | * @author TDM TEAM DEV MODULE |
||
26 | * |
||
27 | */ |
||
28 | |||
29 | /* |
||
30 | * @Class Settings |
||
31 | * @extends \XoopsObject |
||
32 | */ |
||
33 | |||
34 | /** |
||
35 | * Class Settings. |
||
36 | */ |
||
37 | class Settings extends \XoopsObject |
||
38 | { |
||
39 | /** |
||
40 | * Options. |
||
41 | */ |
||
42 | public $options = [ |
||
43 | 'admin', |
||
44 | 'user', |
||
45 | 'blocks', |
||
46 | 'search', |
||
47 | 'comments', |
||
48 | 'notifications', |
||
49 | 'permissions', |
||
50 | //'inroot_copy', |
||
51 | ]; |
||
52 | |||
53 | /** |
||
54 | * @public function constructor class |
||
55 | * |
||
56 | * @param null |
||
57 | */ |
||
58 | public function __construct() |
||
59 | { |
||
60 | $helper = Modulebuilder\Helper::getInstance(); |
||
61 | $this->initVar('set_id', XOBJ_DTYPE_INT); |
||
62 | $this->initVar('set_name', XOBJ_DTYPE_TXTBOX, $helper->getConfig('name')); |
||
63 | $this->initVar('set_dirname', XOBJ_DTYPE_TXTBOX, $helper->getConfig('dirname')); |
||
64 | $this->initVar('set_version', XOBJ_DTYPE_TXTBOX, $helper->getConfig('version')); |
||
65 | $this->initVar('set_since', XOBJ_DTYPE_TXTBOX, $helper->getConfig('since')); |
||
66 | $this->initVar('set_min_php', XOBJ_DTYPE_TXTBOX, $helper->getConfig('min_php')); |
||
67 | $this->initVar('set_min_xoops', XOBJ_DTYPE_TXTBOX, $helper->getConfig('min_xoops')); |
||
68 | $this->initVar('set_min_admin', XOBJ_DTYPE_TXTBOX, $helper->getConfig('min_admin')); |
||
69 | $this->initVar('set_min_mysql', XOBJ_DTYPE_TXTBOX, $helper->getConfig('min_mysql')); |
||
70 | $this->initVar('set_description', XOBJ_DTYPE_TXTAREA, $helper->getConfig('description')); |
||
71 | $this->initVar('set_author', XOBJ_DTYPE_TXTBOX, $helper->getConfig('author')); |
||
72 | $this->initVar('set_author_mail', XOBJ_DTYPE_TXTBOX, $helper->getConfig('author_email')); |
||
73 | $this->initVar('set_author_website_url', XOBJ_DTYPE_TXTBOX, $helper->getConfig('author_website_url')); |
||
74 | $this->initVar('set_author_website_name', XOBJ_DTYPE_TXTBOX, $helper->getConfig('author_website_name')); |
||
75 | $this->initVar('set_credits', XOBJ_DTYPE_TXTBOX, $helper->getConfig('credits')); |
||
76 | $this->initVar('set_license', XOBJ_DTYPE_TXTBOX, $helper->getConfig('license')); |
||
77 | $this->initVar('set_release_info', XOBJ_DTYPE_TXTBOX, $helper->getConfig('release_info')); |
||
78 | $this->initVar('set_release_file', XOBJ_DTYPE_TXTBOX, $helper->getConfig('release_file')); |
||
79 | $this->initVar('set_manual', XOBJ_DTYPE_TXTBOX, $helper->getConfig('manual')); |
||
80 | $this->initVar('set_manual_file', XOBJ_DTYPE_TXTBOX, $helper->getConfig('manual_file')); |
||
81 | $this->initVar('set_image', XOBJ_DTYPE_TXTBOX, $helper->getConfig('image')); |
||
82 | $this->initVar('set_demo_site_url', XOBJ_DTYPE_TXTBOX, $helper->getConfig('demo_site_url')); |
||
83 | $this->initVar('set_demo_site_name', XOBJ_DTYPE_TXTBOX, $helper->getConfig('demo_site_name')); |
||
84 | $this->initVar('set_support_url', XOBJ_DTYPE_TXTBOX, $helper->getConfig('support_url')); |
||
85 | $this->initVar('set_support_name', XOBJ_DTYPE_TXTBOX, $helper->getConfig('support_name')); |
||
86 | $this->initVar('set_website_url', XOBJ_DTYPE_TXTBOX, $helper->getConfig('website_url')); |
||
87 | $this->initVar('set_website_name', XOBJ_DTYPE_TXTBOX, $helper->getConfig('website_name')); |
||
88 | $this->initVar('set_release', XOBJ_DTYPE_TXTBOX, $helper->getConfig('release_date')); |
||
89 | $this->initVar('set_status', XOBJ_DTYPE_TXTBOX, $helper->getConfig('status')); |
||
90 | $this->initVar('set_admin', XOBJ_DTYPE_INT, $helper->getConfig('display_admin')); |
||
91 | $this->initVar('set_user', XOBJ_DTYPE_INT, $helper->getConfig('display_user')); |
||
92 | $this->initVar('set_blocks', XOBJ_DTYPE_INT, $helper->getConfig('active_blocks')); |
||
93 | $this->initVar('set_search', XOBJ_DTYPE_INT, $helper->getConfig('active_search')); |
||
94 | $this->initVar('set_comments', XOBJ_DTYPE_INT, $helper->getConfig('active_comments')); |
||
95 | $this->initVar('set_notifications', XOBJ_DTYPE_INT, $helper->getConfig('active_notifications')); |
||
96 | $this->initVar('set_permissions', XOBJ_DTYPE_INT, $helper->getConfig('active_permissions')); |
||
97 | $this->initVar('set_inroot_copy', XOBJ_DTYPE_INT, $helper->getConfig('inroot_copy')); |
||
98 | $this->initVar('set_donations', XOBJ_DTYPE_TXTBOX, $helper->getConfig('donations')); |
||
99 | $this->initVar('set_subversion', XOBJ_DTYPE_TXTBOX, $helper->getConfig('subversion')); |
||
100 | $this->initVar('set_type', XOBJ_DTYPE_TXTBOX); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @param string $method |
||
105 | * @param array $args |
||
106 | * |
||
107 | * @return mixed |
||
108 | */ |
||
109 | public function __call($method, $args) |
||
110 | { |
||
111 | $arg = isset($args[0]) ? $args[0] : null; |
||
112 | |||
113 | return $this->getVar($method, $arg); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @static function getInstance |
||
118 | * |
||
119 | * @param null |
||
120 | * |
||
121 | * @return Settings |
||
122 | */ |
||
123 | public static function getInstance() |
||
124 | { |
||
125 | static $instance = false; |
||
126 | if (!$instance) { |
||
127 | $instance = new self(); |
||
128 | } |
||
129 | |||
130 | return $instance; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * @public function getForm |
||
135 | * |
||
136 | * @param bool|mixed $action |
||
137 | * @return \XoopsThemeForm |
||
138 | */ |
||
139 | public function getFormSettings($action = false) |
||
140 | { |
||
141 | $helper = Modulebuilder\Helper::getInstance(); |
||
142 | if (false === $action) { |
||
143 | $action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'); |
||
144 | } |
||
145 | |||
146 | $isNew = $this->isNew(); |
||
147 | $title = $isNew ? \sprintf(\_AM_MODULEBUILDER_SETTING_NEW) : \sprintf(\_AM_MODULEBUILDER_SETTING_EDIT); |
||
148 | |||
149 | require_once \XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
150 | |||
151 | $form = new \XoopsThemeForm($title, 'settingform', $action, 'post', true); |
||
152 | $form->setExtra('enctype="multipart/form-data"'); |
||
153 | |||
154 | $form->addElement(new \XoopsFormHidden('set_id', $this->getVar('set_id'))); |
||
155 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_NAME, 'set_name', 50, 255, $this->getVar('set_name'))); |
||
156 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_DIRNAME, 'set_dirname', 25, 255, $this->getVar('set_dirname'))); |
||
157 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_VERSION, 'set_version', 10, 25, $this->getVar('set_version'))); |
||
158 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_SINCE, 'set_since', 10, 25, $this->getVar('set_since'))); |
||
159 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MIN_PHP, 'set_min_php', 10, 25, $this->getVar('set_min_php'))); |
||
160 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MIN_XOOPS, 'set_min_xoops', 10, 25, $this->getVar('set_min_xoops'))); |
||
161 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MIN_ADMIN, 'set_min_admin', 10, 25, $this->getVar('set_min_admin'))); |
||
162 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MIN_MYSQL, 'set_min_mysql', 10, 25, $this->getVar('set_min_mysql'))); |
||
163 | $form->addElement(new \XoopsFormTextArea(\_AM_MODULEBUILDER_SETTING_DESCRIPTION, 'set_description', $this->getVar('set_description'), 4, 25)); |
||
164 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_AUTHOR, 'set_author', 50, 255, $this->getVar('set_author'))); |
||
165 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_LICENSE, 'set_license', 50, 255, $this->getVar('set_license'))); |
||
166 | // Check All Settings Options |
||
167 | $optionsTray = new \XoopsFormElementTray(_OPTIONS, '<br>'); |
||
168 | $checkAllOptions = new \XoopsFormCheckBox('', 'settingbox', 1); |
||
169 | $checkAllOptions->addOption('allbox', \_AM_MODULEBUILDER_SETTING_ALL); |
||
170 | $checkAllOptions->setExtra(' onclick="xoopsCheckAll(\'settingform\', \'settingbox\');" '); |
||
171 | $checkAllOptions->setClass('xo-checkall'); |
||
172 | $optionsTray->addElement($checkAllOptions); |
||
173 | // Options |
||
174 | $settingOption = $this->getOptionsSettings(); |
||
175 | $checkbox = new \XoopsFormCheckbox(' ', 'setting_option', $settingOption, '<br>'); |
||
176 | $checkbox->setDescription(\_AM_MODULEBUILDER_OPTIONS_DESC); |
||
177 | foreach ($this->options as $option) { |
||
178 | $checkbox->addOption($option, self::getDefinedLanguage('\_AM_MODULEBUILDER_SETTING_' . \mb_strtoupper($option))); |
||
179 | } |
||
180 | $optionsTray->addElement($checkbox); |
||
181 | |||
182 | $form->addElement($optionsTray); |
||
183 | |||
184 | $modImage = $this->getVar('set_image'); |
||
185 | //$modImage = $modImage ?: $set['image']; |
||
186 | |||
187 | $uploadDirectory = 'uploads/' . $GLOBALS['xoopsModule']->dirname() . '/images/modules'; |
||
188 | $imgtray = new \XoopsFormElementTray(\_AM_MODULEBUILDER_SETTING_IMAGE, '<br>'); |
||
189 | $imgpath = \sprintf(\_AM_MODULEBUILDER_FORMIMAGE_PATH, './' . $uploadDirectory . '/'); |
||
190 | $imageSelect = new \XoopsFormSelect($imgpath, 'set_image', $modImage); |
||
191 | $modImage_array = \XoopsLists::getImgListAsArray(TDMC_UPLOAD_IMGMOD_PATH); |
||
192 | foreach ($modImage_array as $image) { |
||
193 | $imageSelect->addOption($image, $image); |
||
194 | } |
||
195 | $imageSelect->setExtra("onchange='showImgSelected(\"image3\", \"set_image\", \"" . $uploadDirectory . '", "", "' . \XOOPS_URL . "\")'"); |
||
196 | $imgtray->addElement($imageSelect); |
||
197 | $imgtray->addElement(new \XoopsFormLabel('', "<br><img src='" . TDMC_UPLOAD_IMGMOD_URL . '/' . $modImage . "' id='image3' alt='' /><br>")); |
||
198 | |||
199 | $fileseltray = new \XoopsFormElementTray('', '<br>'); |
||
200 | $fileseltray->addElement(new \XoopsFormFile(\_AM_MODULEBUILDER_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxsize_image'))); |
||
201 | $fileseltray->addElement(new \XoopsFormLabel('')); |
||
202 | $imgtray->addElement($fileseltray); |
||
203 | $form->addElement($imgtray); |
||
204 | |||
205 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_AUTHOR_MAIL, 'set_author_mail', 50, 255, $this->getVar('set_author_mail'))); |
||
206 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_AUTHOR_WEBSITE_URL, 'set_author_website_url', 50, 255, $this->getVar('set_author_website_url'))); |
||
207 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_AUTHOR_WEBSITE_NAME, 'set_author_website_name', 50, 255, $this->getVar('set_author_website_name'))); |
||
208 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_CREDITS, 'set_credits', 50, 255, $this->getVar('set_credits'))); |
||
209 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_RELEASE_INFO, 'set_release_info', 50, 255, $this->getVar('set_release_info'))); |
||
210 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_RELEASE_FILE, 'set_release_file', 50, 255, $this->getVar('set_release_file'))); |
||
211 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MANUAL, 'set_manual', 50, 255, $this->getVar('set_manual'))); |
||
212 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_MANUAL_FILE, 'set_manual_file', 50, 255, $this->getVar('set_manual_file'))); |
||
213 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_DEMO_SITE_URL, 'set_demo_site_url', 50, 255, $this->getVar('set_demo_site_url'))); |
||
214 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_DEMO_SITE_NAME, 'set_demo_site_name', 50, 255, $this->getVar('set_demo_site_name'))); |
||
215 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_SUPPORT_URL, 'set_support_url', 50, 255, $this->getVar('set_support_url'))); |
||
216 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_SUPPORT_NAME, 'set_support_name', 50, 255, $this->getVar('set_support_name'))); |
||
217 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_WEBSITE_URL, 'set_website_url', 50, 255, $this->getVar('set_website_url'))); |
||
218 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_WEBSITE_NAME, 'set_website_name', 50, 255, $this->getVar('set_website_name'))); |
||
219 | $form->addElement(new \XoopsFormTextDateSelect(\_AM_MODULEBUILDER_SETTING_RELEASE, 'set_release', '', $this->getVar('set_release'))); |
||
220 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_STATUS, 'set_status', 50, 255, $this->getVar('set_status'))); |
||
221 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_PAYPAL_BUTTON, 'set_donations', 50, 255, $this->getVar('set_donations'))); |
||
222 | $form->addElement(new \XoopsFormText(\_AM_MODULEBUILDER_SETTING_SUBVERSION, 'set_subversion', 50, 255, $this->getVar('set_subversion'))); |
||
223 | $setTypeRadio = new \XoopsFormRadio(\_AM_MODULEBUILDER_SETTING_TYPE, 'set_type', $this->getVar('set_type')); |
||
224 | $setTypeRadio->addOption(0, \_AM_MODULEBUILDER_SETTING_TYPE_INACTIVE); |
||
225 | $setTypeRadio->addOption(1, \_AM_MODULEBUILDER_SETTING_TYPE_ACTIVE); |
||
226 | $form->addElement($setTypeRadio); |
||
227 | |||
228 | $buttonTray = new \XoopsFormElementTray(_REQUIRED . ' <sup class="red bold">*</sup>', ''); |
||
229 | $buttonTray->addElement(new \XoopsFormHidden('op', 'save')); |
||
230 | $buttonTray->addElement(new \XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
231 | $form->addElement($buttonTray); |
||
232 | |||
233 | return $form; |
||
234 | } |
||
235 | |||
236 | /** |
||
237 | * Get Values. |
||
238 | * |
||
239 | * @param null $keys |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
240 | * @param null $format |
||
0 ignored issues
–
show
|
|||
241 | * @param null $maxDepth |
||
0 ignored issues
–
show
|
|||
242 | * |
||
243 | * @return array |
||
244 | */ |
||
245 | public function getValuesSettings($keys = null, $format = null, $maxDepth = null) |
||
246 | { |
||
247 | $ret = $this->getValues($keys, $format, $maxDepth); |
||
248 | // Values |
||
249 | $ret['id'] = $this->getVar('set_id'); |
||
250 | $ret['name'] = $this->getVar('set_name'); |
||
251 | $ret['version'] = $this->getVar('set_version'); |
||
252 | $ret['image'] = $this->getVar('set_image'); |
||
253 | $ret['release'] = $this->getVar('set_release'); |
||
254 | $ret['status'] = $this->getVar('set_status'); |
||
255 | $ret['type'] = $this->getVar('set_type'); |
||
256 | |||
257 | return $ret; |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * Get Options Settings. |
||
262 | * @return array |
||
263 | */ |
||
264 | private function getOptionsSettings() |
||
265 | { |
||
266 | $retSet = []; |
||
267 | foreach ($this->options as $option) { |
||
268 | if (1 == $this->getVar('set_' . $option)) { |
||
269 | $retSet[] = $option; |
||
270 | } |
||
271 | } |
||
272 | |||
273 | return $retSet; |
||
274 | } |
||
275 | |||
276 | /** |
||
277 | * Get Defined Language. |
||
278 | * |
||
279 | * @param $lang |
||
280 | * |
||
281 | * @return string |
||
282 | */ |
||
283 | private static function getDefinedLanguage($lang) |
||
284 | { |
||
285 | if (\defined($lang)) { |
||
286 | return \constant($lang); |
||
287 | } |
||
288 | |||
289 | return $lang; |
||
290 | } |
||
291 | } |
||
292 |