Issues (519)

Security Analysis    not enabled

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

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Files/admin/AdminXoopsCode.php (3 issues)

1
<?php namespace XoopsModules\Tdmcreate\Files\Admin;
2
3
use XoopsModules\Tdmcreate;
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
 * tdmcreate module.
16
 *
17
 * @copyright       XOOPS Project (https://xoops.org)
18
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
19
 *
20
 * @since           2.5.0
21
 *
22
 * @author          Txmod Xoops http://www.txmodxoops.org
23
 *
24
 * @version         $Id: Axc.php 12258 2014-01-02 09:33:29Z timgno $
25
 */
26
27
/**
28
 * Class Axc.
29
 */
30
class AdminXoopsCode
31
{
32
    /**
33
     *  @static function getInstance
34
     *  @param null
35
     * @return AdminXoopsCode
36
     */
37
    public static function getInstance()
38
    {
39
        static $instance = false;
40
        if (!$instance) {
41
            $instance = new self();
42
        }
43
44
        return $instance;
45
    }
46
47
    /**
48
     * @public function getAdminTemplateMain
49
     * @param        $moduleDirname
50
     * @param        $tableName
51
     *
52
     * @param string $t
53
     * @return string
54
     */
55
    public function getAdminTemplateMain($moduleDirname, $tableName, $t = '')
56
    {
57
        return "{$t}\$templateMain = '{$moduleDirname}_admin_{$tableName}.tpl';\n";
58
    }
59
60
    /**
61
     * @public function getAdminTemplateMain
62
     * @param        $language
63
     * @param        $tableName
64
     * @param        $stuTableSoleName
65
     * @param string $op
66
     * @param string $type
67
     *
68
     * @param string $t
69
     * @return string
70
     */
71
    public function getAdminItemButton($language, $tableName, $stuTableSoleName, $op = '?op=new', $type = 'add', $t = '')
72
    {
73
        $stuType = mb_strtoupper($type);
74
        $aM = $t . '$adminObject->addItemButton(';
75
        if ('add' === $type) {
76
            $ret = $aM . "{$language}ADD_{$stuTableSoleName}, '{$tableName}.php{$op}', '{$type}');\n";
77
        } else {
78
            $ret = $aM . "{$language}{$stuTableSoleName}_{$stuType}, '{$tableName}.php{$op}', '{$type}');\n";
79
        }
80
81
        return $ret;
82
    }
83
84
    /**
85
     * @public function getAdminAddNavigation
86
     *
87
     * @param        $tableName
88
     *
89
     * @param string $t
90
     * @return string
91
     */
92
    public function getAdminDisplayNavigation($tableName, $t = '')
93
    {
94
        return "{$t}\$adminObject->displayNavigation('{$tableName}.php')";
95
    }
96
97
    /**
98
     * @public function getAxcAddInfoBox
99
     * @param        $language
100
     *
101
     * @param string $t
102
     * @return string
103
     */
104
    public function getAxcAddInfoBox($language, $t = '')
105
    {
106
        return "{$t}\$adminObject->addInfoBox({$language});\n";
107
    }
108
109
    /**
110
     * @public function getAxcAddInfoBoxLine
111
     * @param        $language
112
     * @param string $label
113
     * @param string $var
114
     *
115
     * @param string $t
116
     * @return string
117
     */
118
    public function getAxcAddInfoBoxLine($language, $label = '', $var = '', $t = '')
0 ignored issues
show
The parameter $language is not used and could be removed. ( Ignorable by Annotation )

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

118
    public function getAxcAddInfoBoxLine(/** @scrutinizer ignore-unused */ $language, $label = '', $var = '', $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
119
    {
120
        $aMenu = $t . '$adminObject->addInfoBoxLine(sprintf(';
121
        if ('' != $var) {
122
            $ret = $aMenu . " '<label>'.{$label}.'</label>', {$var}));\n";
123
        } else {
124
            $ret = $aMenu . " '<label>'.{$label}.'</label>'));\n";
125
        }
126
127
        return $ret;
128
    }
129
130
    /**
131
     * @public function getAxcAddConfigBoxLine
132
     * @param        $language
133
     * @param string $label
134
     * @param string $var
135
     *
136
     * @param string $t
137
     * @return string
138
     */
139
    public function getAxcAddConfigBoxLine($language, $label = '', $var = '', $t = '')
140
    {
141
        $aMenu = $t . '$adminObject->addConfigBoxLine(';
142
        if ('' != $var) {
143
            $ret = $aMenu . "{$language}, '{$label}', {$var});\n";
144
        } else {
145
            $ret = $aMenu . "{$language}, '{$label}');\n";
146
        }
147
148
        return $ret;
149
    }
150
151
    /**
152
     * @public function getAxcImageListSetVar
153
     * @param string $moduleDirname
154
     * @param string $tableName
155
     * @param string $fieldName
156
     * @param string $t
157
     * @return string
158
     */
159
    public function getAxcImageListSetVar($moduleDirname, $tableName, $fieldName, $t = '')
160
    {
161
        $pCodeImageList = Tdmcreate\Files\CreatePhpCode::getInstance();
162
        $xCodeImageList = Tdmcreate\Files\CreateXoopsCode::getInstance();
163
        $ret = $pCodeImageList->getPhpCodeCommentLine('Set Var', $fieldName, $t);
164
        $ret .= $pCodeImageList->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t);
165
        $xRootPath = "XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32'";
166
        $ret .= $xCodeImageList->getXcMediaUploader('uploader', $xRootPath, $moduleDirname, $t);
167
        $post = $pCodeImageList->getPhpCodeGlobalsVariables('xoops_upload_file', 'POST') . '[0]';
168
        $fetchMedia = $this->getAxcFetchMedia('uploader', $post);
169
        $ifelse = $t . "\t//" . $this->getAxcSetPrefix('uploader', "{$fieldName}_") . ";\n";
170
        $ifelse .= $t . "\t//{$fetchMedia};\n";
171
        $contentElseInt = $xCodeImageList->getXcSetVar($tableName, $fieldName, '$uploader->getSavedFileName()', $t . "\t\t");
172
        $contentIf = $xCodeImageList->getXcEqualsOperator('$errors', '$uploader->getErrors()', null, false, $t . "\t\t");
173
        $contentIf .= $xCodeImageList->getXcRedirectHeader('javascript:history.go(-1)', '', '3', '$errors', true, $t . "\t\t");
174
        $ifelse .= $pCodeImageList->getPhpCodeConditions('!$uploader->upload()', '', '', $contentIf, $contentElseInt, $t . "\t");
175
        $contentElseExt = $xCodeImageList->getXcSetVar($tableName, $fieldName, "\$_POST['{$fieldName}']", $t . "\t");
176
177
        $ret .= $pCodeImageList->getPhpCodeConditions($fetchMedia, '', '', $ifelse, $contentElseExt, $t);
178
179
        return $ret;
180
    }
181
182
    /**
183
     * @public function getAxcUploadImageSetVar
184
     * @param string $moduleDirname
185
     * @param string $tableName
186
     * @param string $fieldName
187
     * @param        $fieldMain
188
     * @param string $t
189
     * @return string
190
     */
191
    public function getAxcUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fieldMain, $t = '')
192
    {
193
        $pCodeUploadImage = Tdmcreate\Files\CreatePhpCode::getInstance();
194
        $xCodeUploadImage = Tdmcreate\Files\CreateXoopsCode::getInstance();
195
        $stuModuleDirname = mb_strtoupper($moduleDirname);
196
        $ret = $pCodeUploadImage->getPhpCodeCommentLine('Set Var', $fieldName, $t);
197
        $ret .= $pCodeUploadImage->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t);
198
        $xUploadImage = "{$stuModuleDirname}_UPLOAD_IMAGE_PATH";
199
        $ret .= $xCodeUploadImage->getXcMediaUploader('uploader', $xUploadImage . ".'/{$tableName}/'", $moduleDirname, $t);
200
        $post = $pCodeUploadImage->getPhpCodeGlobalsVariables('xoops_upload_file', 'POST') . '[0]';
201
        $fetchMedia = $this->getAxcFetchMedia('uploader', $post);
202
        $file = $pCodeUploadImage->getPhpCodeGlobalsVariables('attachedfile', 'FILES') . "['name']";
203
        $expr = '/^.+\.([^.]+)$/sU';
204
        $ifelse = $pCodeUploadImage->getPhpCodePregFunzions('extension', $expr, '', $file, 'replace', false, $t . "\t");
205
206
        $ifelse .= $t . "\t\$imgName = str_replace(' ', '', \$_POST['{$fieldMain}']).'.'.\$extension;\n";
207
        $ifelse .= $this->getAxcSetPrefix('uploader', '$imgName', $t . "\t") . ";\n";
208
        $ifelse .= $t . "\t{$fetchMedia};\n";
209
        $contentElseInt = $xCodeUploadImage->getXcSetVar($tableName, $fieldName, '$uploader->getSavedFileName()', $t . "\t\t");
210
        $contentIf = $xCodeUploadImage->getXcEqualsOperator('$errors', '$uploader->getErrors()', null, false, $t . "\t\t");
211
        $contentIf .= $xCodeUploadImage->getXcRedirectHeader('javascript:history.go(-1)', '', '3', '$errors', true, $t . "\t\t");
212
        $ifelse .= $pCodeUploadImage->getPhpCodeConditions('!$uploader->upload()', '', '', $contentIf, $contentElseInt, $t . "\t");
213
        $contentElseExt = $xCodeUploadImage->getXcSetVar($tableName, $fieldName, "\$_POST['{$fieldName}']", $t . "\t");
214
215
        $ret .= $pCodeUploadImage->getPhpCodeConditions($fetchMedia, '', '', $ifelse, $contentElseExt, $t);
216
217
        return $ret;
218
    }
219
220
    /**
221
     * @public function getAxcFileSetVar
222
     * @param        $moduleDirname
223
     * @param        $tableName
224
     * @param        $fieldName
225
     * @param bool   $formatUrl
226
     * @param string $t
227
     * @return string
228
     */
229
    public function getAxcUploadFileSetVar($moduleDirname, $tableName, $fieldName, $formatUrl = false, $t = '')
230
    {
231
        $stuModuleDirname = mb_strtoupper($moduleDirname);
232
        $ret = $this->getAxcImageFileSetVar($moduleDirname, $stuModuleDirname . '_UPLOAD_FILES_PATH', $tableName, $fieldName, $formatUrl, $t);
233
234
        return $ret;
235
    }
236
237
    /**
238
     * @private function getAxcImageFileSetVar
239
     * @param        $moduleDirname
240
     * @param        $dirname
241
     * @param        $tableName
242
     * @param        $fieldName
243
     * @param bool   $formatUrl
244
     * @param string $t
245
     * @return string
246
     */
247
    private function getAxcImageFileSetVar($moduleDirname, $dirname, $tableName, $fieldName, $formatUrl = false, $t = '')
248
    {
249
        $pCodeFileSetVar = Tdmcreate\Files\CreatePhpCode::getInstance();
250
        $xCodeFileSetVar = Tdmcreate\Files\CreateXoopsCode::getInstance();
251
        $ret = '';
252
        $ifelse = '';
253
        $files = '';
254
        $post = $pCodeFileSetVar->getPhpCodeGlobalsVariables('xoops_upload_file', 'POST') . '[0]';
255
        $fetchMedia = $this->getAxcFetchMedia('uploader', $post);
256
        if ($formatUrl) {
257
            $ret .= $xCodeFileSetVar->getXcSetVar($tableName, $fieldName, "formatUrl(\$_REQUEST['{$fieldName}'])", $t);
258
            $ret .= $pCodeFileSetVar->getPhpCodeCommentLine('Set Var', $fieldName, $t);
259
            $ifelse .= $t . "\t\t{$fetchMedia};\n";
260
        } else {
261
            $files = '/files';
262
            $ret .= $pCodeFileSetVar->getPhpCodeCommentLine('Set Var', $fieldName, $t);
263
            $ifelse .= $t . "\t//" . $this->getAxcSetPrefix('uploader', "'{$fieldName}_'") . ";\n";
264
            $ifelse .= $t . "\t//{$fetchMedia};\n";
265
        }
266
        $ret .= $pCodeFileSetVar->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t);
267
        $ret .= $xCodeFileSetVar->getXcMediaUploader('uploader', $dirname . ".'/{$tableName}{$files}'", $moduleDirname, $t);
268
        $contentElse = $xCodeFileSetVar->getXcSetVar($tableName, $fieldName, '$uploader->getSavedFileName()', $t . "\t\t");
269
        $contentIf = $xCodeFileSetVar->getXcEqualsOperator('$errors', '$uploader->getErrors()', null, false, $t . "\t\t");
270
        $contentIf .= $xCodeFileSetVar->getXcRedirectHeader('javascript:history.go(-1)', '', '3', '$errors', true, $t . "\t\t");
271
        $ifelse .= $pCodeFileSetVar->getPhpCodeConditions('!$uploader->upload()', '', '', $contentIf, $contentElse, $t . "\t");
272
273
        $ret .= $pCodeFileSetVar->getPhpCodeConditions($fetchMedia, '', '', $t . "\t" . $fetchMedia . ";\n", $ifelse, $t);
274
275
        return $ret;
276
    }
277
278
    /**
279
     * @public function getAxcSetVarsObjects
280
     *
281
     * @param $moduleDirname
282
     * @param $tableName
283
     * @param $tableSoleName
284
     * @param $fields
285
     * @return string
286
     */
287
    public function getAxcSetVarsObjects($moduleDirname, $tableName, $tableSoleName, $fields)
288
    {
289
        $xCodeSetVars = Tdmcreate\Files\CreateXoopsCode::getInstance();
290
        $ret = Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine($comment = 'Set Vars', $var = '');
291
        $fieldMain = '';
292
        foreach (array_keys($fields) as $f) {
293
            $fieldName = $fields[$f]->getVar('field_name');
294
            $fieldElement = $fields[$f]->getVar('field_element');
295
            if ($f > 0) { // If we want to hide field id
296
                switch ($fieldElement) {
297
                    case 5:
298
                    case 6:
299
                        $ret .= $xCodeSetVars->getXcCheckBoxOrRadioYNSetVar($tableName, $fieldName);
300
                        break;
301
                    case 11:
302
                        $ret .= $this->getAxcImageListSetVar($moduleDirname, $tableName, $fieldName);
303
                        break;
304
                    case 12:
305
                        $ret .= $xCodeSetVars->getXcUrlFileSetVar($moduleDirname, $tableName, $fieldName);
0 ignored issues
show
The method getXcUrlFileSetVar() does not exist on XoopsModules\Tdmcreate\Files\CreateXoopsCode. Did you maybe mean getXcUrlFileGetVar()? ( Ignorable by Annotation )

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

305
                        $ret .= $xCodeSetVars->/** @scrutinizer ignore-call */ getXcUrlFileSetVar($moduleDirname, $tableName, $fieldName);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
306
                        break;
307
                    case 13:
308
                        if (1 == $fields[$f]->getVar('field_main')) {
309
                            $fieldMain = $fieldName;
310
                        }
311
                        $ret .= $this->getAxcUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fieldMain);
312
                        break;
313
                    case 14:
314
                        $ret .= $xCodeSetVars->getXcUploadFileSetVar($moduleDirname, $tableName, $fieldName);
0 ignored issues
show
The method getXcUploadFileSetVar() does not exist on XoopsModules\Tdmcreate\Files\CreateXoopsCode. Did you maybe mean getXcUploadImageGetVar()? ( Ignorable by Annotation )

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

314
                        $ret .= $xCodeSetVars->/** @scrutinizer ignore-call */ getXcUploadFileSetVar($moduleDirname, $tableName, $fieldName);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
315
                        break;
316
                    case 15:
317
                        $ret .= $xCodeSetVars->getXcTextDateSelectSetVar($tableName, $tableSoleName, $fieldName);
318
                        break;
319
                    default:
320
                        $ret .= $xCodeSetVars->getXcSetVar($tableName, $fieldName, "\$_POST['{$fieldName}']");
321
                        break;
322
                }
323
            }
324
        }
325
326
        return $ret;
327
    }
328
329
    /**
330
     * @public function getAxcFetchMedia
331
     *
332
     * @param        $anchor
333
     * @param        $var
334
     *
335
     * @param string $t
336
     * @return string
337
     */
338
    public function getAxcFetchMedia($anchor, $var, $t = '')
339
    {
340
        return "{$t}\${$anchor}->fetchMedia({$var})";
341
    }
342
343
    /**
344
     * @public function getAxcSetPrefix
345
     *
346
     * @param        $anchor
347
     * @param        $var
348
     *
349
     * @param string $t
350
     * @return string
351
     */
352
    public function getAxcSetPrefix($anchor, $var, $t = '')
353
    {
354
        return "{$t}\${$anchor}->setPrefix({$var})";
355
    }
356
357
    /**
358
     * @public function getAxcGetObjHandlerId
359
     *
360
     * @param string $tableName
361
     * @param string $fieldId
362
     *
363
     * @param string $t
364
     * @return string
365
     */
366
    public function getAxcGetObjHandlerId($tableName, $fieldId, $t = '')
367
    {
368
        return "{$t}\${$tableName}Obj = \${$tableName}Handler->get(\${$fieldId});\n";
369
    }
370
371
    /**
372
     * @public function getAdminCodeCaseDelete
373
     * @param        $language
374
     * @param        $tableName
375
     * @param        $fieldId
376
     * @param        $fieldMain
377
     * @param string $t
378
     * @return string
379
     */
380
    public function getAdminCodeCaseDelete($language, $tableName, $fieldId, $fieldMain, $t = '')
381
    {
382
        $phpCodeCaseDelete = Tdmcreate\Files\CreatePhpCode::getInstance();
383
        $xCodeCaseDelete = Tdmcreate\Files\CreateXoopsCode::getInstance();
384
        $ccFieldId = Tdmcreate\Files\CreateFile::getInstance()->getCamelCase($fieldId, false, true);
385
        $ret = $xCodeCaseDelete->getXcGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler');
386
387
        $reqOk = "_REQUEST['ok']";
388
        $isset = $phpCodeCaseDelete->getPhpCodeIsset($reqOk);
389
        $xoopsSecurityCheck = $xCodeCaseDelete->getXcSecurityCheck();
390
        $xoopsSecurityErrors = $xCodeCaseDelete->getXcSecurityErrors();
391
        $implode = $phpCodeCaseDelete->getPhpCodeImplode(', ', $xoopsSecurityErrors);
392
        $redirectHeaderErrors = $xCodeCaseDelete->getXcRedirectHeader($tableName, '', '3', $implode, true, $t . "\t\t");
393
394
        $delete = $xCodeCaseDelete->getXcDelete($tableName, $tableName, 'Obj', 'Handler');
395
        $condition = $phpCodeCaseDelete->getPhpCodeConditions('!' . $xoopsSecurityCheck, '', '', $redirectHeaderErrors, false, $t . "\t");
396
397
        $redirectHeaderLanguage = $xCodeCaseDelete->getXcRedirectHeader($tableName, '', '3', "{$language}FORM_DELETE_OK", true, $t . "\t\t");
398
        $htmlErrors = $xCodeCaseDelete->getXcHtmlErrors($tableName, true);
399
        $internalElse = $xCodeCaseDelete->getXcTplAssign('error', $htmlErrors, true, $t . "\t\t");
400
        $condition .= $phpCodeCaseDelete->getPhpCodeConditions($delete, '', '', $redirectHeaderLanguage, $internalElse, $t . "\t");
401
402
        $mainElse = $xCodeCaseDelete->getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, 'delete', $t . "\t");
403
        $ret .= $phpCodeCaseDelete->getPhpCodeConditions($isset, ' && ', "1 == \${$reqOk}", $condition, $mainElse, $t);
404
405
        return $ret;
406
    }
407
}
408