Issues (621)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

class/Form.php (20 issues)

Upgrade to new PHP Analysis Engine

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\Smallworld;
4
5
/**
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * SmallWorld
17
 *
18
 * @package      \XoopsModules\Smallworld
19
 * @license      GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/)
20
 * @copyright    The XOOPS Project (https://xoops.org)
21
 * @copyright    2011 Culex
22
 * @author       Michael Albertsen (http://culex.dk) <[email protected]>
23
 * @link         https://github.com/XoopsModules25x/smallworld
24
 * @since        1.0
25
 */
26
27
 /**
28
 * Form Class
29
 *
30
 * creates HTML entities to display in forms
31
 *
32
 */
33
class Form
34
{
35
    /**
36
     * Create a dropdown select
37
     *
38
     * @param string $name
39
     * @param array  $options
40
     * @param string $selected (optional)
0 ignored issues
show
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
41
     * @param string $sep (optional)
42
     * @return string
43
     */
44
    public function dropdown($name, array $options, $selected = null, $sep = '<br>')
45
    {
46
        $dropdown = "<select name='{$name}' id='{$name}'>\n";
47
        foreach ($options as $key => $option) {
48
            $select    = $selected == $key ? ' selected' : '';
49
            $dropdown .= "<option value='{$key}'{$selected}>{$option}</option>\n";
50
        }
51
        $dropdown .= "</select>{$sep}";
52
53
        return $dropdown;
54
    }
55
56
    /**
57
     * Create a radio select
58
	 *
59
     * @param string $name
60
     * @param array  $options
61
     * @param string $selected (optional)
0 ignored issues
show
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
62
     * @param string $sep (optional)
63
     * @return string
64
     */
65
    public function radio($name, array $options, $selected = null, $sep = '<br>')
66
    {
67
        $selected = $selected;
68
        $form     = '';
69
        $i = 0;
70
        foreach ($options as $value => $option) {
71
            $select = $selected == $value ? ' checked' : '';
72
            $form   .= "<label for='{$name}-{$i}'><input type='radio' name='{$name}[]' id='{$name}-{$i}' value='{$value}'{$select}> "
73
            . "{$option}</label>{$sep}\n";
74
//            $form   .= "<input type='checkbox' name='{$name}[]' id='{$name}-{$i}' value='{$value}'{$select}> "
75
//            . "<label for='{$name}-{$i}'>{$option}</label>{$sep}\n";
76
            $i++;
77
        }
78
79
        return $form;
80
    }
81
82
    /**
83
	 * Create a HTML checkbox element
84
	 *
85
     * @param string $name
86
     * @param array  $options
87
     * @param array  $valuearray
88
     * @param string $selected (optional)
0 ignored issues
show
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
89
     * @param string $sep (optional)
90
     * @return string
91
     */
92
    public function retrieveRadio($name, $options, $valuearray, $selected = null, $sep = '<br>')
93
    {
94
        $form = '';
95
        $a    = count($options) - 1;
96
        for ($i = 0; $i <= $a; ++$i) {
97
            if (in_array($i, $valuearray)) {
98
                $form .= "<input type='checkbox' id='{$name}-{$i}' name='{$name}[]' value='{$i}' checked> "
99
                . "<label for='{$name}-{$i}'>{$options[$i]}</label>{$sep}";
100
            } else {
101
                $form .= "<input type='checkbox' id='{$name}-{$i}' name='{$name}[]' value='{$i}'> "
102
                . "<label for='{$name}-{$i}'>{$options[$i]}</label>{$sep}";
103
            }
104
        }
105
106
        return $form;
107
    }
108
109
    /**
110
	 * Create a HTML text input element
111
	 *
112
     * @param string $name
113
     * @param string $id
114
     * @param string $class
115
     * @param int    $size   (optional)
0 ignored issues
show
Should the type for parameter $size not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
116
     * @param string $preset (optional)
0 ignored issues
show
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
117
     * @return string
118
     */
119 View Code Duplication
    public function input($name, $id, $class, $size = null, $preset = null)
120
    {
121
        $s    = $size ?: '50px';
122
        $data = "<input type='text' size='" . $s . "' name='" . $name . "' id='" . $id . "' class='" . $class . "' value='" . $preset . "'>";
123
124
        return $data;
125
    }
126
127
    /**
128
	 * Create a HTML hidden element
129
	 *
130
     * @param string $name
131
     * @param string $id
132
     * @param string $preset (optional)
0 ignored issues
show
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
133
     * @return string
134
     */
135
    public function hidden($name, $id, $preset = null)
136
    {
137
        $data = "<input type='hidden' name='" . $name . "' value='" . $preset . "' >";
138
139
        return $data;
140
    }
141
142
    /**
143
	 * Returns simple text string
144
	 *
145
     * @param string $value
146
     * @return string
147
     */
148
    public function simpleText($value)
149
    {
150
        $data = $value;
151
152
        return $data;
153
    }
154
155
    /**
156
	 * Create a HTML select (dropdown) element
157
	 *
158
     * @param string  $class
159
     * @param string  $name
160
     * @param         $name2
161
     * @param string  $rel
162
     * @param array   $options
163
     * @param string  $textmore
164
     * @param string  $selected (optional)
0 ignored issues
show
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
165
     * @param string  $preset   (optional)
0 ignored issues
show
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
166
     * @return string
167
     */
168
    public function dropdown_add($class, $name, $name2, $rel, array $options, $textmore, $selected = null, $preset = null)
169
    {
170
        $dropdown = '<span id="' . $name . '"><input type="text" name="' . $name2 . '[]" value="' . $preset . '">';
171
        $dropdown .= '<select class="smallworld_select" name="' . $name . '[]" id="' . $name . '">' . '<br>';
172 View Code Duplication
        foreach ($options as $key => $option) {
173
            $select   = $selected == $key ? ' selected' : null;
174
            $dropdown .= '<option value="' . $key . '"' . $select . '>' . $option . '</option>' . '<br>';
175
        }
176
        $dropdown .= '</select></span>';
177
178
        return $dropdown;
179
    }
180
181
    /**
182
     * @param string  $class
183
     * @param string  $name
184
     * @param         $name2
185
     * @param string  $rel
186
     * @param int     $size
187
     * @param string  $textmore
188
     * @param string  $preset (optional)
0 ignored issues
show
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
189
     * @param string  $id     (optional)
0 ignored issues
show
Should the type for parameter $id not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
190
     * @return string
191
     */
192 View Code Duplication
    public function input_add($class, $name, $name2, $rel, $size, $textmore, $preset = null, $id = null)
193
    {
194
        $s    = $size ?: '50px';
195
        $i    = $id ?: '';
196
        $data = "<span id='" . $name . "'><input type='text' size='" . $s . "' name='" . $name2 . "[]' value='" . $preset . "' id='" . $i . "'></span>";
197
198
        return $data;
199
    }
200
201
    /**
202
     * @param string $name
203
     * @param string $id
204
     * @param string $title
205
     * @param string $rows
206
     * @param string $cols
207
     * @param string $class
208
     * @param string $preset (optional)
0 ignored issues
show
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
209
     * @return string
210
     * @return string
211
     */
212
    public function textarea($name, $id, $title, $rows, $cols, $class, $preset = null)
213
    {
214
        return "<textarea name='" . $name . "' id='" . $id . "'  title='" . $title . "' rows='" . $rows . "' cols='" . $cols . "' class='" . $class . "'>" . $preset . '</textarea>';
215
    }
216
217
    /**
218
     * @param string $class
219
     * @param string $name
220
     * @param string $name2
221
     * @param string $rel
222
     * @param array  $options
223
     * @param string $textmore
224
     * @param string $selected      (optional)
0 ignored issues
show
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
225
     * @param string $preset        (optional)
0 ignored issues
show
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
226
     * @param string $selectedstart (optional)
0 ignored issues
show
Should the type for parameter $selectedstart not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
227
     * @param string $selectedstop  (optional)
0 ignored issues
show
Should the type for parameter $selectedstop not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
228
     * @return string
229
     */
230
    public function school_add(
231
        $class,
232
        $name,
233
        $name2,
234
        $rel,
235
        array $options,
236
        $textmore,
237
        $selected = null,
238
        $preset = null,
239
        $selectedstart = null,
240
        $selectedstop = null
241
    ) {
242
        $dropdown = '<div id="' . $name . '"><p class="smallworld_clonebreaker">' . _SMALLWORLD_SCHOOLNAME . '<input class="school" type="text" value="' . $preset . '" name="' . $name2 . '[]">'
243
                  . '<br><br>' . _SMALLWORLD_SCHOOLTYPE . '<select class="school" name="' . $name . '[]" id="' . $name . '"">' . '<br>';
244 View Code Duplication
        foreach ($options as $key => $option) {
245
            $select   = $selected == $key ? ' selected="selected"' : null;
246
            $dropdown .= '<option  class="school" value="' . $key . '"' . $select . '>' . $option . '</option>' . '<br>';
247
        }
248
        $dropdown .= '</select>'
249
                   . '<br><br>'
250
                   . _SMALLWORLD_START . '<select class="schooltime" name="schoolstart[]" id="schoolstart">';
251
        $array    = SmallworldGetTimestampsToForm();
252 View Code Duplication
        foreach ($array as $key => $option) {
253
            $selectstart = $selectedstart == $key ? ' selected="selected"' : null;
254
            $dropdown    .= '<option value="' . $key . '"' . $selectstart . '>' . $option . '</option>' . '<br>';
255
        }
256
        $dropdown .= '</select>'
257
                   . '<br><br>'
258
                   . _SMALLWORLD_STOP . '<select class="schooltime" name="schoolstop[]" id="schoolstop">';
259
        $array    = SmallworldGetTimestampsToForm();
260 View Code Duplication
        foreach ($array as $key => $option) {
261
            $selectstop = $selectedstop == $key ? ' selected="selected"' : null;
262
            $dropdown   .= '<option value="' . $key . '"' . $selectstop . '>' . $option . '</option>' . '<br>';
263
        }
264
        $dropdown .= '</select><br></p></div>';
265
266
        return $dropdown;
267
    }
268
269
    /**
270
     * Create HTML form elements for Job fields
271
     *
272
     * @param string  $class - not used
273
     * @param string  $name
274
     * @param string  $name2 - not used
275
     * @param string  $rel   - not used
276
     * @param string  $textmore - not used
277
     * @param string  $employer      (optional)
0 ignored issues
show
Should the type for parameter $employer not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
278
     * @param string  $position      (optional)
0 ignored issues
show
Should the type for parameter $position not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
279
     * @param string  $selectedstart (optional)
0 ignored issues
show
Should the type for parameter $selectedstart not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
280
     * @param string  $selectedstop  (optional)
0 ignored issues
show
Should the type for parameter $selectedstop not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
281
     * @param string  $description   (optional)
0 ignored issues
show
Should the type for parameter $description not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
282
     * @return string
283
     */
284
    public function job(
285
        $class,
286
        $name,
287
        $name2,
288
        $rel,
289
        $textmore,
290
        $employer = null,
291
        $position = null,
292
        $selectedstart = null,
293
        $selectedstop = null,
294
        $description = null
295
    ) {
296
        $text = '<div id="' . $name . '"><p class="smallworld_clonebreaker">' . _SMALLWORLD_EMPLOYER . '<input class="job" id="job" value="' . $employer . '" type="text" name="employer[]">'
297
              . '<br><br>' . _SMALLWORLD_POSITION . '<input class="job" type="text" value="' . $position . '" name="position[]">'
298
              . '<br><br>' . _SMALLWORLD_JOBSTART . '<input class="jobstart" type="text" value="' . $selectedstart . '" name="jobstart[]">'
299
              . '<br><br>' . _SMALLWORLD_JOBSTOP . '<input class="jobstop" value="' . $selectedstop . '" type="text" name="jobstop[]">'
300
              . '<br><br><span class="jobdescText">' . _SMALLWORLD_DESCRIPTION . '</span><textarea class="jobdesc" name="description[]" rows="20" cols="20">' . $description . '</textarea><br></p></div>'
301
              . '' . '<br>';
302
303
        return $text;
304
    }
305
306
    /**
307
     * Create a HTML upload form
308
     *
309
     * @param int $userID - not used
310
     * @return string
311
     */
312
    public function uploadform($userID)
313
    {
314
        $text = '<form action="' . Helper::getInstance()->url('imgupload.php') . '" method="POST" enctype="multipart/form-data">'
315
              . '<input type="file" name="file[]" multiple>'
316
              . '<button type="submit">' . _SMALLWORLD_UPLOADTEXT . '</button>'
317
              . '<span class="file_upload_label">' . _SMALLWORLD_UPLOADFILESTEXT . '</span>'
318
              . '</form>';
319
320
        return $text;
321
    }
322
323
    /**
324
     * @param int    $userID - not used
325
     * @param string $imgurl
326
     * @param string $imgdesc
327
     * @param string $id
328
     * @return string
329
     */
330
    public function edit_images($userID, $imgurl, $imgdesc, $id)
331
    {
332
        $text = '<p class="smallworld_clonebreaker"><br>'
333
              . '<table class="smallworld_table" border="0" cellspacing="0" cellpadding="0">'
334
              . '<tr>'
335
              . '<td><img class="smallworld_edit_image" src="' . $imgurl . '" height="100px" width="80px;"></td>'
336
              . '<td><span class="smallworld_editTextSpan">' . _SMALLWORLD_UPLOADDESC . '</span><br><br><textarea class="smallworld_edit_desc" name="imgdesc[]" rows="1" cols="1">' . stripslashes($imgdesc) . '</textarea><br><br></td>'
337
              . '<input value="' . $id . '" type="hidden" name="id[]">'
338
              . '</tr></table></p>';
339
340
        return $text;
341
    }
342
343
    /**
344
     * Create HTML radio selects for user settings
345
     *
346
     * @param int $userid
347
     * @return string
348
     */
349
    public function usersettings($userid)
350
    {
351
        $form = "<div style='display:none'><div class='smallworld_usersetings'>";
352
        $form .= '<fieldset><legend>' . _SMALLWORLD_SHOWIFPUBLICORPRIVATE . '</legend>';
353
        $form .= "<form id='perset'>";
354
        if ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser'] instanceof \XoopsUser) {
355
            $sql    = 'SELECT value FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_settings') . ' WHERE userid = ' . (int)$userid;
356
            $result = $GLOBALS['xoopsDB']->queryF($sql);
357
            $i      = $GLOBALS['xoopsDB']->getRowsNum($result);
358
            $v      = [];
359
            if ($i >= 1) {
360
                while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
361
                    $v    = unserialize(stripslashes($row['value']));
362
                    $pv   = ('1' == $v['posts']) ? ' checked' : '';
363
                    $cv   = ('1' == $v['comments']) ? ' checked' : '';
364
                    $nv   = ('1' == $v['notify']) ? ' checked' : '';
365
                    $form .= '<input type="checkbox" name="usersettings[]" id="posts" value="' . $v['posts'] . '" ' . $pv . '> ' . _SMALLWORLD_SHOWMYPOSTS . '<br>';
366
                    $form .= '<input type="checkbox" name="usersettings[]" id="comments" value="' . $v['comments'] . '" ' . $cv . '> ' . _SMALLWORLD_SHOWMYCOMMENTS . '<br>';
367
                    $form .= '<input type="checkbox" name="usersettings[]" id="notify" value="' . $v['notify'] . '" ' . $nv . '> ' . _SMALLWORLD_NOTIFYME . '<br>';
368
                }
369
            } else {
370
                $form .= '<input type="checkbox" name="usersettings[]" id="posts" value="0"> ' . _SMALLWORLD_SHOWMYPOSTS . '<br>';
371
                $form .= '<input type="checkbox" name="usersettings[]" id="comments" value="0"> ' . _SMALLWORLD_SHOWMYCOMMENTS . '<br>';
372
                $form .= '<input type="checkbox" name="usersettings[]" id="notify" value="0"> ' . _SMALLWORLD_NOTIFYME . '<br>';
373
            }
374
        }
375
        $form .= "<br><input type='submit' id='smallworld_privsave' value='" . _SMALLWORLD_SUBMIT . "' class='smallworld_finish'>";
376
        $form .= '</form></fieldset></div></div>';
377
378
        return $form;
379
    }
380
}
381