Issues (314)

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.

Templates/Blocks/Defstyle/TemplatesBlocks.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace XoopsModules\Modulebuilder\Files\Templates\Blocks\Defstyle;
4
5
use XoopsModules\Modulebuilder;
6
use XoopsModules\Modulebuilder\Files;
7
8
/*
9
 You may not change or alter any portion of this comment or credits
10
 of supporting developers from this source code or any supporting source code
11
 which is considered copyrighted (c) material of the original comment or credit authors.
12
13
 This program is distributed in the hope that it will be useful,
14
 but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
 */
17
/**
18
 * modulebuilder module.
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.0
24
 *
25
 * @author          Txmod Xoops https://xoops.org 
26
 *                  Goffy https://myxoops.org
27
 *
28
 */
29
30
/**
31
 * Class TemplatesBlocks.
32
 */
33
class TemplatesBlocks extends Files\CreateFile
34
{
35
    /**
36
     * @var mixed
37
     */
38
    private $hc = null;
39
40
    /**
41
     * @var mixed
42
     */
43
    private $sc = null;
44
45
    /**
46
     * @public function constructor
47
     * @param null
48
     */
49
    public function __construct()
50
    {
51
        parent::__construct();
52
        $this->hc = Modulebuilder\Files\CreateHtmlCode::getInstance();
53
        $this->sc = Modulebuilder\Files\CreateSmartyCode::getInstance();
54
    }
55
56
    /**
57
     * @static function getInstance
58
     * @param null
59
     * @return TemplatesBlocks
60
     */
61
    public static function getInstance()
62
    {
63
        static $instance = false;
64
        if (!$instance) {
65
            $instance = new self();
66
        }
67
68
        return $instance;
69
    }
70
71
    /**
72
     * @public function write
73
     * @param string $module
74
     * @param string $table
75
     * @param string $filename
76
     */
77
    public function write($module, $table, $filename)
78
    {
79
        $this->setModule($module);
80
        $this->setTable($table);
81
        $this->setFileName($filename);
82
    }
83
84
    /**
85
     * @private  function getTemplatesBlocksTableThead
86
     * @param        $tableId
87
     * @param        $tableMid
88
     * @param string $language
89
     * @param $tableAutoincrement
90
     * @return string
91
     */
92
    private function getTemplatesBlocksTableThead($tableId, $tableMid, $language, $tableAutoincrement)
93
    {
94
        $th     = '';
95
		if (1 == $tableAutoincrement) {
96
            $th .= $this->hc->getHtmlTableHead('&nbsp;', '', '', "\t\t\t");
97
        }
98
        $fields = $this->getTableFields($tableMid, $tableId);
99
        foreach (\array_keys($fields) as $f) {
100
            if (1 === (int)$fields[$f]->getVar('field_block')) {
101
                $fieldName    = $fields[$f]->getVar('field_name');
102
                $stuFieldName = \mb_strtoupper($fieldName);
103
                $lang         = $this->sc->getSmartyConst($language, $stuFieldName);
104
                $th           .= $this->hc->getHtmlTableHead($lang, 'center', '', "\t\t\t");
105
            }
106
        }
107
        $tr = $this->hc->getHtmlTableRow($th, 'head', "\t\t");
108
109
        return $this->hc->getHtmlTableThead($tr, '', "\t");
110
    }
111
112
    /**
113
     * @private  function getTemplatesBlocksTableTbody
114
     * @param string $moduleDirname
115
     * @param        $tableId
116
     * @param        $tableMid
117
     * @param        $tableName
118
     * @param        $tableSoleName
119
     * @param        $tableAutoincrement
120
     * @param        $language
121
     * @return string
122
     */
123
    private function getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language)
124
    {
125
        $td = '';
126
        $fieldId = '';
127
        $stuTableSoleName = \mb_strtoupper($tableSoleName);
128
        if (1 == $tableAutoincrement) {
129
            $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id');
130
            $td     .= $this->hc->getHtmlTableData($double, 'center',  '', "\t\t\t");
131
        }
132
        $fields = $this->getTableFields($tableMid, $tableId);
133
        foreach (\array_keys($fields) as $f) {
134
            if (0 == $f) {
135
                $fieldId = $fields[$f]->getVar('field_name');
136
            }
137
            if (1 === (int)$fields[$f]->getVar('field_block')) {
138
                $fieldName    = $fields[$f]->getVar('field_name');
139
                $fieldElement = $fields[$f]->getVar('field_element');
140
                $rpFieldName  = $this->getRightString($fieldName);
141
                if (1 == $fields[$f]->getVar('field_inlist')) {
142
                    switch ($fieldElement) {
143
                        case 9:
144
                            $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
145
                            $span   = $this->hc->getHtmlTag('span', [], $double);
146
                            $td     .= $this->hc->getHtmlTableData($span, 'center',  '', "\t\t\t");
147
                            break;
148
                        case 10:
149
                            $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32');
150
                            $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
151
                            $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, '', '');
152
                            $td  .= $this->hc->getHtmlTableData($img, 'center',  '', "\t\t\t");
153
                            break;
154
                        case 13:
155
                            $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url');
156
                            $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
157
                            $img    = $this->hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName], '', true, '', '');
158
                            $td     .= $this->hc->getHtmlTableData($img, 'center',  '', "\t\t\t");
159
                            break;
160
                        default:
161
                            if (0 != $f) {
162
                                $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
163
                                $td     .= $this->hc->getHtmlTableData($double, 'center',  '', "\t\t\t");
164
                            }
165
                            break;
166
                    }
167
                }
168
            }
169
        }
170
        // TODO: allow edit only for admins
171
		// $lang    = $this->sc->getSmartyConst('', '_EDIT');
172
		// $double  = $this->sc->getSmartyDoubleVar($tableSoleName, 'id');
173
		// $src     = $this->sc->getSmartyNoSimbol('xoModuleIcons32 edit.png');
174
		// $img     = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, '', '');
175
		// $anchor  = $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=edit&amp;{$fieldId}=" . $double, 'title' => $lang], $img, false, "\t\t\t\t");
176
		// $lang    = $this->sc->getSmartyConst('', '_DELETE');
177
		// $double  = $this->sc->getSmartyDoubleVar($tableSoleName, 'id');
178
		// $src     = $this->sc->getSmartyNoSimbol('xoModuleIcons32 delete.png');
179
		// $img     = $this->hc->getHtmlTag('img', ['src' => $src . $double, 'alt' => $tableName], '', true, '', '');
180
		// $anchor  .= $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=delete&amp;{$fieldId}=" . $double, 'title' => $lang], $img, false, "\t\t\t\t");
181
		// $td      .= $this->hc->getHtmlTag('td', ['class' => 'center'], "\n" . $anchor . "\t\t\t", false, "\t\t\t");
182
        $double  = $this->sc->getSmartyDoubleVar($tableSoleName, 'id');
183
        $lang    = $this->sc->getSmartyConst($language, $stuTableSoleName . '_GOTO');
184
        $anchor  = $this->hc->getHtmlAnchor($tableName . ".php?op=show&amp;{$fieldId}=" . $double, $lang, $lang);
185
        $td     .= $this->hc->getHtmlTableData($anchor, 'center',  '', "\t\t\t");
186
		$cycle   = $this->sc->getSmartyNoSimbol('cycle values="odd, even"');
187
		$tr 	 = $this->hc->getHtmlTableRow($td, $cycle, "\t\t");
188
        $foreach = $this->sc->getSmartyForeach($tableSoleName, 'block', $tr, '','', "\t\t");
189
        $tbody   = $this->hc->getHtmlTableTbody($foreach,'' , "\t");
190
191
        return $this->sc->getSmartyConditions("block", '', '', $tbody, false, true, true, "\t");
192
    }
193
194
    /**
195
     * @private  function getTemplatesBlocksTfoot
196
     * @return string
197
     */
198
    private function getTemplatesBlocksTableTfoot()
199
    {
200
        $td = $this->hc->getHtmlTag('td', [], "&nbsp;", false, '', '');
201
        $tr = $this->hc->getHtmlTag('tr', [], $td, false, '', '');
202
203
        return $this->hc->getHtmlTag('tfoot', [], $tr, false, "\t");
204
    }
205
206
    /**
207
     * @private  function getTemplatesBlocksTable
208
     * @param string $moduleDirname
209
     * @param        $tableId
210
     * @param        $tableMid
211
     * @param string $tableName
212
     * @param        $tableSoleName
213
     * @param        $tableAutoincrement
214
     * @param string $language
215
     * @return string
216
     */
217
    private function getTemplatesBlocksTable($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language)
218
    {
219
        $tbody  = $this->getTemplatesBlocksTableThead($tableId, $tableMid, $language, $tableAutoincrement);
220
        $tbody  .= $this->getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language);
221
        $tbody  .= $this->getTemplatesBlocksTableTfoot();
222
        $single = $this->sc->getSmartySingleVar('table_type');
223
224
        return $this->hc->getHtmlTable($tbody, 'table table-' . $single);
225
    }
226
227
    /**
228
     * @public function render
229
     * @param null
230
     *
231
     * @return bool|string
232
     */
233
    public function render()
234
    {
235
        $module             = $this->getModule();
236
        $table              = $this->getTable();
237
        $filename           = $this->getFileName();
238
        $moduleDirname      = $module->getVar('mod_dirname');
239
        $tableId            = $table->getVar('table_id');
240
        $tableMid           = $table->getVar('table_mid');
241
        $tableName          = $table->getVar('table_name');
242
        $tableSoleName      = $table->getVar('table_solename');
243
        $tableAutoincrement = $table->getVar('table_autoincrement');
244
        $language           = $this->getLanguage($moduleDirname, 'MB', '', false);
0 ignored issues
show
false of type false is incompatible with the type string expected by parameter $addFq of XoopsModules\Modulebuild...eateFile::getLanguage(). ( Ignorable by Annotation )

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

244
        $language           = $this->getLanguage($moduleDirname, 'MB', '', /** @scrutinizer ignore-type */ false);
Loading history...
245
        $content            = $this->getTemplatesBlocksTable($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language);
246
247
        $this->create($moduleDirname, 'templates/blocks', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED);
248
249
        return $this->renderFile();
250
    }
251
}
252