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/User/UserIndex.php (13 issues)

1
<?php namespace XoopsModules\Tdmcreate\Files\User;
2
3
use XoopsModules\Tdmcreate;
4
use XoopsModules\Tdmcreate\Files;
5
6
/*
7
 You may not change or alter any portion of this comment or credits
8
 of supporting developers from this source code or any supporting source code
9
 which is considered copyrighted (c) material of the original comment or credit authors.
10
11
 This program is distributed in the hope that it will be useful,
12
 but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 */
15
/**
16
 * tdmcreate module.
17
 *
18
 * @copyright       XOOPS Project (https://xoops.org)
19
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
20
 *
21
 * @since           2.5.0
22
 *
23
 * @author          Txmod Xoops http://www.txmodxoops.org
24
 *
25
 * @version         $Id: user_index.php 12258 2014-01-02 09:33:29Z timgno $
26
 */
27
28
/**
29
 * Class UserIndex.
30
 */
31
class UserIndex extends Files\CreateFile
32
{
33
    /**
34
     *  @public function constructor
35
     *  @param null
36
     */
37
    public function __construct()
38
    {
39
        parent::__construct();
40
    }
41
42
    /**
43
     *  @static function getInstance
44
     *  @param null
45
     * @return UserIndex
46
     */
47
    public static function getInstance()
48
    {
49
        static $instance = false;
50
        if (!$instance) {
51
            $instance = new self();
52
        }
53
54
        return $instance;
55
    }
56
57
    /**
58
     * @public function write
59
     * @param string $module
60
     * @param        $table
61
     * @param string $filename
62
     */
63
    public function write($module, $table, $filename)
64
    {
65
        $this->setModule($module);
66
        $this->setTable($table);
67
        $this->setFileName($filename);
68
    }
69
70
    /**
71
     * @private function getTemplateHeaderFile
72
     * @param $moduleDirname
73
     *
74
     * @return string
75
     */
76
    private function getTemplateHeaderFile($moduleDirname)
77
    {
78
        $pc = Tdmcreate\Files\CreatePhpCode::getInstance();
79
        $xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
80
        $uc = UserXoopsCode::getInstance();
81
        $cc = Tdmcreate\Files\Classes\ClassXoopsCode::getInstance();
0 ignored issues
show
The assignment to $cc is dead and can be removed.
Loading history...
82
        $ret = $this->getInclude();
83
        $ret .= $uc->getUserTplMain($moduleDirname);
84
        $ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true);
85
        $ret .= $pc->getPhpCodeCommentLine('Define Stylesheet');
86
        $ret .= $xc->getXcAddStylesheet();
87
        $ret .= $pc->getPhpCodeArray('keywords', null, false, '');
88
89
        return $ret;
90
    }
91
92
    /**
93
     * @private  function getBodyCategoriesIndex
94
     * @param $moduleDirname
95
     * @param $tableMid
96
     * @param $tableId
97
     * @param $tableName
98
     * @param $tableSoleName
99
     * @param $tableFieldname
100
     * @return string
101
     */
102
    private function getBodyCategoriesIndex($moduleDirname, $tableMid, $tableId, $tableName, $tableSoleName, $tableFieldname)
103
    {
104
        $ucfTableName = ucfirst($tableName);
0 ignored issues
show
The assignment to $ucfTableName is dead and can be removed.
Loading history...
105
        // Fields
106
        $fields = $this->getTableFields($tableMid, $tableId);
107
        $fieldParentId = [];
108
        foreach (array_keys($fields) as $f) {
109
            $fieldName = $fields[$f]->getVar('field_name');
110
            if (0 == $f) {
111
                $fieldId = $fieldName; // fieldMain = fields parameters main field
0 ignored issues
show
The assignment to $fieldId is dead and can be removed.
Loading history...
112
            }
113
            $fieldParentId[] = $fields[$f]->getVar('field_parent');
114
            if (1 == $fields[$f]->getVar('field_main')) {
115
                $fieldMain = $fieldName; // fieldMain = fields parameters main field
0 ignored issues
show
The assignment to $fieldMain is dead and can be removed.
Loading history...
116
            }
117
            if (1 == $fields[$f]->getVar('field_parent')) {
118
                $fieldParent = $fieldName; // fieldMain = fields parameters main field
0 ignored issues
show
The assignment to $fieldParent is dead and can be removed.
Loading history...
119
            }
120
        }
121
        $ret = '';
122
        $pc = Tdmcreate\Files\CreatePhpCode::getInstance();
123
        $xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
124
        $cc = Tdmcreate\Files\Classes\ClassXoopsCode::getInstance();
0 ignored issues
show
The assignment to $cc is dead and can be removed.
Loading history...
125
        if (in_array(1, $fieldParentId)) {
126
            $ret .= $xc->getXcObjHandlerCount($tableName);
127
            $ret .= $pc->getPhpCodeCommentLine('If there are ', $tableName);
128
            $ret .= $this->getSimpleString('$count = 1;');
129
130
            $contentIf = $xc->getXcObjHandlerAll($tableName, '', 0, 0, "\t");
131
            $contentIf .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/tree', true, false, 'include', "\t");
132
            //$contentIf .= $cc->getClassXoopsObjectTree('mytree', $tableName, $fieldId, $fieldParent, "\t");
133
            $contentIf .= $pc->getPhpCodeArray($tableName, "\t");
134
            $foreach = $xc->getXcGetValues($tableName, $tableSoleName . 'Values', $tableFieldname, false, "\t");
135
            $foreach .= $pc->getPhpCodeArray('acount', ["'count'", '$count']);
136
            $foreach .= $pc->getPhpCodeArrayType($tableName, 'merge', $tableSoleName . 'Values', '$acount');
137
            $foreach .= $this->getSimpleString('++$count;', "\t\t");
138
            $contentIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, $tableFieldname, $foreach, "\t");
139
            $contentIf .= $xc->getXcTplAssign($tableName, '$' . $tableName, true, "\t");
140
            $contentIf .= $pc->getPhpCodeUnset($tableName, "\t");
141
            $getConfig = $xc->getXcGetConfig($moduleDirname, 'numb_col');
142
            $contentIf .= $xc->getXcTplAssign('numb_col', $getConfig, true, "\t");
143
            $ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contentIf, false);
144
            $ret .= $pc->getPhpCodeUnset('count');
145
        }
146
        unset($fieldParentId);
147
148
        return $ret;
149
    }
150
151
    /**
152
     * @private function getBodyPagesIndex
153
     * @param $moduleDirname
154
     * @param $tableName
155
     * @param $tableSoleName
156
     * @param $tableFieldname
157
     * @param $language
158
     * @return string
159
     */
160
    private function getBodyPagesIndex($moduleDirname, $tableName, $tableSoleName, $tableFieldname, $language)
0 ignored issues
show
The parameter $tableFieldname 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

160
    private function getBodyPagesIndex($moduleDirname, $tableName, $tableSoleName, /** @scrutinizer ignore-unused */ $tableFieldname, $language)

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...
161
    {
162
        $pc = Tdmcreate\Files\CreatePhpCode::getInstance();
163
        $xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
164
        $stuModuleDirname = mb_strtoupper($moduleDirname);
0 ignored issues
show
The assignment to $stuModuleDirname is dead and can be removed.
Loading history...
165
        $ucfTableName = ucfirst($tableName);
0 ignored issues
show
The assignment to $ucfTableName is dead and can be removed.
Loading history...
166
        $stuModuleDirname = mb_strtoupper($moduleDirname);
167
        $ucfTableName = ucfirst($tableName);
168
        $ret = $pc->getPhpCodeCommentLine();
169
        $ret .= $xc->getXcTplAssign('xoops_icons32_url', 'XOOPS_ICONS32_URL');
170
        $ret .= $xc->getXcTplAssign("{$moduleDirname}_url", "{$stuModuleDirname}_URL");
171
        $ret .= $pc->getPhpCodeCommentLine();
172
        $ret .= $xc->getXcObjHandlerCount($tableName);
173
        $ret .= $this->getSimpleString('$count = 1;');
174
        $condIf = $xc->getXcXoopsRequest('start', 'start', '0', 'Int', false, "\t");
175
        $userpager = $xc->getXcGetConfig($moduleDirname, 'userpager');
176
        $condIf .= $xc->getXcXoopsRequest('limit', 'limit', $userpager, 'Int', false, "\t");
177
        $condIf .= $xc->getXcObjHandlerAll($tableName, '', '$start', '$limit', "\t");
178
        $condIf .= $pc->getPhpCodeCommentLine('Get All', $ucfTableName, "\t");
179
        $condIf .= $pc->getPhpCodeArray($tableName, null, false, "\t");
180
        $foreach = $xc->getXcGetValues($tableName, $tableSoleName, 'i', false, "\t");
181
        $foreach .= $pc->getPhpCodeArray('acount', ["'count'", '$count']);
182
        $foreach .= $pc->getPhpCodeArrayType($tableName, 'merge', $tableSoleName, '$acount');
183
        $table = $this->getTable();
184
        // Fields
185
        $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
186
        foreach (array_keys($fields) as $f) {
187
            $fieldName = $fields[$f]->getVar('field_name');
188
            if (1 == $fields[$f]->getVar('field_main')) {
189
                $fieldMain = $fieldName; // fieldMain = fields parameters main field
190
            }
191
        }
192
        $foreach .= $xc->getXcGetVar('keywords[]', "{$tableName}All[\$i]", $fieldMain, false, "\t\t");
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldMain does not seem to be defined for all execution paths leading up to this point.
Loading history...
193
        $foreach .= $this->getSimpleString('++$count;', "\t\t");
194
        $condIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, "\t");
195
        $condIf .= $xc->getXcTplAssign($tableName, '$' . $tableName, true, "\t");
196
        $condIf .= $pc->getPhpCodeUnset($tableName, "\t");
197
        $condIf .= $xc->getXcPageNav($tableName, "\t");
198
        $thereare = $pc->getPhpCodeSprintf("{$language}INDEX_THEREARE", "\${$tableName}Count");
199
        $condIf .= $xc->getXcTplAssign('lang_thereare', $thereare, true, "\t");
200
        $divideby = $xc->getXcGetConfig($moduleDirname, 'divideby');
201
        $condIf .= $xc->getXcTplAssign('divideby', $divideby, true, "\t");
202
203
        $ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $condIf);
204
        $ret .= $pc->getPhpCodeUnset('count');
205
        $tableType = $xc->getXcGetConfig($moduleDirname, 'table_type');
206
        $ret .= $xc->getXcTplAssign('table_type', $tableType);
207
208
        return $ret;
209
    }
210
211
    /**
212
     * @private  function getUserPagesFooter
213
     * @param $moduleDirname
214
     * @param $language
215
     * @return string
216
     */
217
    private function getUserIndexFooter($moduleDirname, $language)
218
    {
219
        $pc = Tdmcreate\Files\CreatePhpCode::getInstance();
220
        $xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
221
        $uc = UserXoopsCode::getInstance();
222
        $stuModuleDirname = mb_strtoupper($moduleDirname);
223
        $ret = $pc->getPhpCodeCommentLine('Breadcrumbs');
224
        $ret .= $uc->getUserBreadcrumbs($language);
225
        $ret .= $pc->getPhpCodeCommentLine('Keywords');
226
        $ret .= $uc->getUserMetaKeywords($moduleDirname);
227
        $ret .= $pc->getPhpCodeUnset('keywords');
228
        $ret .= $pc->getPhpCodeCommentLine('Description');
229
        $ret .= $uc->getUserMetaDesc($moduleDirname, $language);
230
        $ret .= $xc->getXcTplAssign('xoops_mpageurl', "{$stuModuleDirname}_URL.'/index.php'");
231
        $ret .= $xc->getXcTplAssign('xoops_icons32_url', 'XOOPS_ICONS32_URL');
232
        $ret .= $xc->getXcTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL");
233
        $ret .= $this->getInclude('footer');
234
235
        return $ret;
236
    }
237
238
    /**
239
     *  @public function render
240
     *  @param null
241
     * @return bool|string
242
     */
243
    public function render()
244
    {
245
        $module = $this->getModule();
246
        $table = $this->getTable();
0 ignored issues
show
The assignment to $table is dead and can be removed.
Loading history...
247
        $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order');
248
        $filename = $this->getFileName();
249
        $moduleDirname = $module->getVar('mod_dirname');
250
        $language = $this->getLanguage($moduleDirname, 'MA');
251
        $content = $this->getHeaderFilesComments($module, $filename);
252
        $content .= $this->getTemplateHeaderFile($moduleDirname);
253
        foreach (array_keys($tables) as $t) {
254
            $tableId = $tables[$t]->getVar('table_id');
255
            $tableMid = $tables[$t]->getVar('table_mid');
256
            $tableName = $tables[$t]->getVar('table_name');
257
            $tableSoleName = $tables[$t]->getVar('table_solename');
258
            $tableCategory[] = $tables[$t]->getVar('table_category');
259
            $tableFieldname = $tables[$t]->getVar('table_fieldname');
260
            $tableIndex[] = $tables[$t]->getVar('table_index');
261
            if (in_array(1, $tableCategory, true) && in_array(1, $tableIndex)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $tableCategory seems to be defined later in this foreach loop on line 258. Are you sure it is defined here?
Loading history...
Comprehensibility Best Practice introduced by
The variable $tableIndex seems to be defined later in this foreach loop on line 260. Are you sure it is defined here?
Loading history...
262
                $content .= $this->getBodyCategoriesIndex($moduleDirname, $tableMid, $tableId, $tableName, $tableSoleName, $tableFieldname);
263
            }
264
            if (in_array(0, $tableCategory, true) && in_array(1, $tableIndex)) {
265
                $content .= $this->getBodyPagesIndex($moduleDirname, $tableName, $tableSoleName, $tableFieldname, $language);
266
            }
267
        }
268
        $content .= $this->getUserIndexFooter($moduleDirname, $language);
269
270
        $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
271
272
        return $this->renderFile();
273
    }
274
}
275