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/Includes/IncludeSearch.php (3 issues)

1
<?php namespace XoopsModules\Tdmcreate\Files\Includes;
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: IncludeSearch.php 12258 2014-01-02 09:33:29Z timgno $
26
 */
27
28
/**
29
 * Class IncludeSearch.
30
 */
31
class IncludeSearch extends Files\CreateFile
32
{
33
    /**
34
    *  @public function constructor
35
    *  @param null
36
    */
37
38
    public function __construct()
39
    {
40
        parent::__construct();
41
        $this->tdmcfile = Tdmcreate\Files\CreateFile::getInstance();
0 ignored issues
show
Bug Best Practice introduced by
The property tdmcfile does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
42
    }
43
44
    /**
45
    *  @static function getInstance
46
    *  @param null
47
     * @return IncludeSearch
48
     */
49
    public static function getInstance()
50
    {
51
        static $instance = false;
52
        if (!$instance) {
53
            $instance = new self();
54
        }
55
56
        return $instance;
57
    }
58
59
    /**
60
    *  @public function write
61
    *  @param string $module
62
    *  @param mixed $table
63
    *  @param string $filename
64
     */
65
    public function write($module, $table, $filename)
66
    {
67
        $this->setModule($module);
68
        $this->setFileName($filename);
69
        $this->setTable($table);
70
    }
71
72
    /**
73
    *  @static function getSearchField
74
    *  @param string $fieldSearch
75
    *  @param string $options
76
     *
77
     * @return string
78
     */
79
    public function getSearchField($fieldSearch, $options)
80
    {
81
        // fieldSearch = fields parameters search field
82
        $sql = '';
83
        if (isset($fieldSearch)) {
84
            $nb_fieldSearch = count($fieldSearch);
0 ignored issues
show
$fieldSearch of type string is incompatible with the type Countable|array expected by parameter $var of count(). ( Ignorable by Annotation )

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

84
            $nb_fieldSearch = count(/** @scrutinizer ignore-type */ $fieldSearch);
Loading history...
85
            $sql .= '(';
86
            for ($i = 0; $i < $nb_fieldSearch; ++$i) {
87
                if ($i != $nb_fieldSearch - 1) {
88
                    $sql .= ''.$fieldSearch[$i].' LIKE %$queryarray['.$options.']% OR ';
89
                } else {
90
                    $sql .= ''.$fieldSearch[$i].' LIKE %$queryarray[0]%';
91
                }
92
            }
93
            $sql .= ')';
94
        }
95
96
        return $sql;
97
    }
98
99
    /**
100
    *  @static function getSearchFunction
101
     * @param $moduleDirname
102
     *
103
     * @return string
104
     */
105
    public function getSearchFunction($moduleDirname)
106
    {
107
        $table = $this->getTable();
108
        $tableName = $table->getVar('table_name');
109
        $tableFieldname = $table->getVar('table_fieldname');
110
        $fieldId = '';
111
        $fieldSearch = null;
112
        $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
113
        foreach (array_keys($fields) as $f) {
114
            $fieldName = $fields[$f]->getVar('field_name');
115
            if ((0 == $f) && (1 == $table->getVar('table_autoincrement'))) {
116
                $fieldId = $fieldName;
117
            }
118
            if (1 == $fields[$f]->getVar('field_main')) {
119
                $fieldMain = $fieldName;
120
            }
121
            if (1 == $fields[$f]->getVar('field_search')) {
122
                $fieldSearch = $fieldName;
123
            }
124
        }
125
        $img_search = 'blank.gif';
126
        $ret = <<<EOT
127
\n
128
/**
129
 * search callback functions
130
 * @param \$queryarray
131
 * @param \$andor
132
 * @param \$limit
133
 * @param \$offset
134
 * @param \$userid
135
 */
136
function {$moduleDirname}_search(\$queryarray, \$andor, \$limit, \$offset, \$userid)
137
{
138
    global \$xoopsDB;
139
    \$sql = "SELECT '{$fieldId}', '{$fieldMain}' FROM " . \$xoopsDB->prefix('{$moduleDirname}_{$tableName}') . ' WHERE {$fieldId} != 0';
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...
140
    if ( \$userid != 0 ) {
141
        \$sql .= ' AND {$tableFieldname}_submitter='.(int)\$userid;
142
    }
143
    if ( is_array(\$queryarray) && \$count = count(\$queryarray) )
144
    {
145
        \$sql .= " AND (
146
EOT;
147
        $ret .= $this->getSearchField($fieldSearch, 0).'";';
148
        $ret .= <<<EOT
149
150
        for(\$i = 1; \$i < \$count; ++\$i)
151
        {
152
            \$sql .= " \$andor ";
153
            \$sql .= "{$this->getSearchField($fieldSearch, '$i')}";
154
        }
155
        \$sql .= ')';
156
    }
157
    \$sql .= " ORDER BY '{$fieldId}' DESC";
158
    \$result = \$xoopsDB->query(\$sql,\$limit,\$offset);
159
    \$ret = array();
160
    \$i = 0;
161
    while(\$myrow = \$xoopsDB->fetchArray(\$result))
162
    {
163
        \$ret[\$i]['image'] = 'assets/icons/32/{$img_search}';
164
        \$ret[\$i]['link'] = '{$tableName}.php?{$fieldId}='.\$myrow['{$fieldId}'];
165
        \$ret[\$i]['title'] = \$myrow['{$fieldMain}'];
166
        ++\$i;
167
    }
168
    unset(\$i);
169
}
170
EOT;
171
172
        return $ret;
173
    }
174
175
    /**
176
    *  @public function render
177
    *  @param null
178
     * @return bool|string
179
     */
180
    public function render()
181
    {
182
        $module = $this->getModule();
183
        $filename = $this->getFileName();
184
        $moduleDirname = $module->getVar('mod_dirname');
185
        $content = $this->getHeaderFilesComments($module, $filename);
186
        $content .= $this->getSearchFunction($moduleDirname);
187
188
        $this->tdmcfile->create($moduleDirname, 'include', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
189
190
        return $this->tdmcfile->renderFile();
191
    }
192
}
193