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.

Files/Templates/Admin/TemplatesAdminPages.php (9 issues)

1
<?php namespace XoopsModules\Tdmcreate\Files\Templates\Admin;
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: TemplatesAdminPages.php 12258 2014-01-02 09:33:29Z timgno $
26
 */
27
28
/**
29
 * Class TemplatesAdminPages.
30
 */
31
class TemplatesAdminPages 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 TemplatesAdminPages
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 string $table
61
     * @param        $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 getTemplatesAdminPagesHeader
72
     *  @param string $moduleDirname
73
     *  @return string
74
     */
75
    private function getTemplatesAdminPagesHeader($moduleDirname)
76
    {
77
        $hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance();
78
        $ret = $hc->getHtmlComment('Header') . PHP_EOL;
79
        $ret .= $hc->getSmartyIncludeFile($moduleDirname, 'header', true);
80
81
        return $ret;
82
    }
83
84
    /**
85
     * @private  function getTemplatesAdminPagesTableThead
86
     * @param        $tableSoleName
87
     * @param        $tableAutoincrement
88
     * @param string $fields
89
     * @param string $language
90
     * @return string
91
     */
92
    private function getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincrement, $fields, $language)
93
    {
94
        $hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance();
95
        $th = '';
96
        $langHeadId = mb_strtoupper($tableSoleName) . '_ID';
97
        if (1 == $tableAutoincrement) {
98
            $lang = $hc->getSmartyConst($language, $langHeadId);
99
            $th .= $hc->getHtmlTag('th', ['class' => 'center'], $lang, false, false, "\t\t\t");
0 ignored issues
show
false of type false is incompatible with the type string expected by parameter $t of XoopsModules\Tdmcreate\F...artyCodes::getHtmlTag(). ( Ignorable by Annotation )

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

99
            $th .= $hc->getHtmlTag('th', ['class' => 'center'], $lang, false, /** @scrutinizer ignore-type */ false, "\t\t\t");
Loading history...
The call to XoopsModules\Tdmcreate\F...artyCodes::getHtmlTag() has too many arguments starting with ' '. ( Ignorable by Annotation )

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

99
            $th .= $hc->/** @scrutinizer ignore-call */ getHtmlTag('th', ['class' => 'center'], $lang, false, false, "\t\t\t");

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
100
        }
101
        foreach (array_keys($fields) as $f) {
0 ignored issues
show
$fields of type string is incompatible with the type array expected by parameter $input of array_keys(). ( Ignorable by Annotation )

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

101
        foreach (array_keys(/** @scrutinizer ignore-type */ $fields) as $f) {
Loading history...
102
            $fieldName = $fields[$f]->getVar('field_name');
103
            $rpFieldName = $this->getRightString($fieldName);
104
            $langFieldName = mb_strtoupper($tableSoleName) . '_' . mb_strtoupper($rpFieldName);
105
            if (1 == $fields[$f]->getVar('field_inlist')) {
106
                $lang = $hc->getSmartyConst($language, $langFieldName);
107
                $th .= $hc->getHtmlTag('th', ['class' => 'center'], $lang, false, false, "\t\t\t");
108
            }
109
        }
110
111
        $lang = $hc->getSmartyConst($language, 'FORM_ACTION');
112
        $th .= $hc->getHtmlTag('th', ['class' => 'center width5'], $lang, false, false, "\t\t\t");
113
        $tr = $hc->getHtmlTag('tr', ['class' => 'head'], $th) . PHP_EOL;
114
        $ret = $hc->getHtmlTag('thead', [], $tr);
115
116
        return $ret;
117
    }
118
119
    /**
120
     * @private  function getTemplatesAdminPagesTableTBody
121
     * @param string $moduleDirname
122
     * @param string $tableName
123
     * @param        $tableSoleName
124
     * @param        $tableAutoincrement
125
     * @param string $fields
126
     * @return string
127
     * @internal param string $language
128
     */
129
    private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields)
130
    {
131
        $hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance();
132
        $td = '';
133
        if (1 == $tableAutoincrement) {
134
            $double = $hc->getSmartyDoubleVar($tableSoleName, 'id');
135
            $td .= $hc->getHtmlTableData($double, 'center');
136
        }
137
        foreach (array_keys($fields) as $f) {
0 ignored issues
show
$fields of type string is incompatible with the type array expected by parameter $input of array_keys(). ( Ignorable by Annotation )

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

137
        foreach (array_keys(/** @scrutinizer ignore-type */ $fields) as $f) {
Loading history...
138
            $fieldName = $fields[$f]->getVar('field_name');
139
            $fieldElement = $fields[$f]->getVar('field_element');
140
            $rpFieldName = $this->getRightString($fieldName);
141
            if (0 == $f) {
142
                $fieldId = $fieldName;
143
            }
144
            if (1 == $fields[$f]->getVar('field_inlist')) {
145
                switch ($fieldElement) {
146
                    case 9:
147
                        // This is to be reviewed, as it was initially to style = "backgroung-color: #"
148
                        // Now with HTML5 is not supported inline style in the parameters of the HTML tag
149
                        // Old code was <span style="background-color: #<{\$list.{$rpFieldName}}>;">...
150
                        $double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
151
                        $span = $hc->getHtmlTag('span', [], $double);
152
                        $td .= $hc->getHtmlTag('td', ['class' => 'center'], $span);
153
                        /*$ret .= <<<EOT
154
                    <td class="center"><span style="background-color: #<{\$list.{$rpFieldName}}>;">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>\n
155
EOT;*/
156
                        break;
157
                    case 10:
158
                        $src = $hc->getSmartyNoSimbol('xoModuleIcons32');
159
                        $src .= $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
160
                        $img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, false);
0 ignored issues
show
false of type false is incompatible with the type string expected by parameter $t of XoopsModules\Tdmcreate\F...artyCodes::getHtmlTag(). ( Ignorable by Annotation )

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

160
                        $img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, /** @scrutinizer ignore-type */ false);
Loading history...
161
                        $td .= $hc->getHtmlTag('td', ['class' => 'center'], "\n\t" . $img);
162
                        break;
163
                    case 13:
164
                        $single = $hc->getSmartySingleVar($moduleDirname . '_upload_url');
165
                        $double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
166
                        $img = $hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName, 'style' => 'max-width:100px'], '', true, false);
167
                        $td .= $hc->getHtmlTag('td', ['class' => 'center'], $img, false, false, "\t\t");
0 ignored issues
show
The call to XoopsModules\Tdmcreate\F...artyCodes::getHtmlTag() has too many arguments starting with ' '. ( Ignorable by Annotation )

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

167
                        $td .= $hc->/** @scrutinizer ignore-call */ getHtmlTag('td', ['class' => 'center'], $img, false, false, "\t\t");

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
168
                        break;
169
                    default:
170
                        if (0 != $f) {
171
                            $double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
172
                            $td .= $hc->getHtmlTag('td', ['class' => 'center'], $double);
173
                        }
174
                        break;
175
                }
176
            }
177
        }
178
        $lang = $hc->getSmartyConst('', '_EDIT');
179
        $double = $hc->getSmartyDoubleVar($tableSoleName, 'id');
180
        $src = $hc->getSmartyNoSimbol('xoModuleIcons16 edit.png');
181
        $img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, false);
182
        $anchor = $hc->getHtmlTag('a', ['href' => $tableName . ".php?op=edit&amp;{$fieldId}=" . $double, 'title' => $lang], "\n\t" . $img);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldId does not seem to be defined for all execution paths leading up to this point.
Loading history...
183
        $lang = $hc->getSmartyConst('', '_DELETE');
184
        $double = $hc->getSmartyDoubleVar($tableSoleName, 'id');
185
        $src = $hc->getSmartyNoSimbol('xoModuleIcons16 delete.png');
186
        $img = $hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, false);
187
        $anchor .= $hc->getHtmlTag('a', ['href' => $tableName . ".php?op=delete&amp;{$fieldId}=" . $double, 'title' => $lang], "\n\t" . $img);
188
        $td .= $hc->getHtmlTag('td', ['class' => 'center  width5'], "\n" . $anchor);
189
        $cycle = $hc->getSmartyNoSimbol('cycle values=\'odd, even\'');
190
        $tr = $hc->getHtmlTag('tr', ['class' => $cycle], $td);
191
        $foreach = $hc->getSmartyForeach($tableSoleName, $tableName . '_list', $tr);
192
        $tbody = $hc->getHtmlTag('tbody', [], $foreach);
193
194
        return $hc->getSmartyConditions($tableName . '_count', '', '', $tbody);
195
    }
196
197
    /**
198
     * @private function getTemplatesAdminPagesTable
199
     * @param string $moduleDirname
200
     * @param string $tableName
201
     * @param        $tableSoleName
202
     * @param        $tableAutoincrement
203
     * @param string $fields
204
     * @param string $language
205
     * @return string
206
     */
207
    private function getTemplatesAdminPagesTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language)
208
    {
209
        $hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance();
210
        $tbody = $this->getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincrement, $fields, $language);
211
        $tbody .= $this->getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields);
212
213
        return $hc->getHtmlTable($tbody, 'table table-bordered');
214
    }
215
216
    /**
217
     * @private function getTemplatesAdminPages
218
     * @param string $moduleDirname
219
     * @param string $tableName
220
     * @param        $tableSoleName
221
     * @param        $tableAutoincrement
222
     * @param string $fields
223
     * @param string $language
224
     * @return string
225
     */
226
    private function getTemplatesAdminPages($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language)
227
    {
228
        $hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance();
229
        $htmlTable = $this->getTemplatesAdminPagesTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language);
230
        $htmlTable .= $hc->getHtmlTag('div', ['class' => 'clear'], '&nbsp;');
231
        $single = $hc->getSmartySingleVar('pagenav');
232
        $div = $hc->getHtmlTag('div', ['class' => 'xo-pagenav floatright'], $single);
233
        $div .= $hc->getHtmlTag('div', ['class' => 'clear spacer'], '');
234
        $htmlTable .= $hc->getSmartyConditions('pagenav', '', '', $div);
235
        $ifList = $hc->getSmartyConditions($tableName . '_list', '', '', $htmlTable);
236
        $single = $hc->getSmartySingleVar('form');
237
        $divComm = $hc->getHtmlComment('Display navigation');
0 ignored issues
show
The assignment to $divComm is dead and can be removed.
Loading history...
238
        //$divComm .= $hc->getHtmlTag('div', array('class' => 'errorMsg'), $single);
239
        $ifList .= $hc->getSmartyConditions('form', '', '', $single);
240
        $single = $hc->getSmartySingleVar('error');
241
        $strong = $hc->getHtmlTag('strong', [], $single);
242
        $div = $hc->getHtmlTag('div', ['class' => 'errorMsg'], $strong);
243
        $ifList .= $hc->getSmartyConditions('error', '', '', $div);
244
245
        return $ifList;
246
    }
247
248
    /**
249
     *  @private function getTemplatesAdminPagesFooter
250
     *  @param string $moduleDirname
251
     *  @return string
252
     */
253
    private function getTemplatesAdminPagesFooter($moduleDirname)
254
    {
255
        $hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance();
256
        $ret = $hc->getHtmlTag('br', [], '', true);
257
        $ret .= $hc->getHtmlComment('Footer');
258
        $ret .= $hc->getSmartyIncludeFile($moduleDirname, 'footer', true);
259
260
        return $ret;
261
    }
262
263
    /**
264
     *  @public function render
265
     *  @param null
266
     *  @return bool|string
267
     */
268
    public function render()
269
    {
270
        $module = $this->getModule();
271
        $table = $this->getTable();
272
        $filename = $this->getFileName();
273
        $moduleDirname = $module->getVar('mod_dirname');
274
        $language = $this->getLanguage($moduleDirname, 'AM');
275
        $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'), 'field_order');
276
        $content = $this->getTemplatesAdminPagesHeader($moduleDirname);
277
        $content .= $this->getTemplatesAdminPages($moduleDirname, $table->getVar('table_name'), $table->getVar('table_solename'), $table->getVar('table_autoincrement'), $fields, $language);
0 ignored issues
show
$fields of type array is incompatible with the type string expected by parameter $fields of XoopsModules\Tdmcreate\F...etTemplatesAdminPages(). ( Ignorable by Annotation )

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

277
        $content .= $this->getTemplatesAdminPages($moduleDirname, $table->getVar('table_name'), $table->getVar('table_solename'), $table->getVar('table_autoincrement'), /** @scrutinizer ignore-type */ $fields, $language);
Loading history...
278
        $content .= $this->getTemplatesAdminPagesFooter($moduleDirname);
279
280
        $this->create($moduleDirname, 'templates/admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
281
282
        return $this->renderFile();
283
    }
284
}
285