This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||||
2 | /* |
||||
3 | You may not change or alter any portion of this comment or credits of |
||||
4 | supporting developers from this source code or any supporting source code |
||||
5 | which is considered copyrighted (c) material of the original comment or credit |
||||
6 | authors. |
||||
7 | |||||
8 | This program is distributed in the hope that it will be useful, but |
||||
9 | WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
11 | */ |
||||
12 | |||||
13 | /** |
||||
14 | * Module: Pedigree |
||||
15 | * |
||||
16 | * @package XoopsModules\Pedigree |
||||
17 | * @author XOOPS Module Development Team |
||||
18 | * @copyright Copyright (c) 2001-2019 {@link https://xoops.org XOOPS Project} |
||||
19 | * @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
||||
20 | */ |
||||
21 | |||||
22 | use Xmf\Request; |
||||
0 ignored issues
–
show
|
|||||
23 | use XoopsModules\Pedigree; |
||||
24 | |||||
25 | //require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
||||
26 | require_once __DIR__ . '/header.php'; |
||||
27 | |||||
28 | $moduleDirName = basename(__DIR__); |
||||
29 | xoops_loadLanguage('main', $moduleDirName); |
||||
30 | |||||
31 | // Include any common code for this module. |
||||
32 | require_once XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'; |
||||
33 | |||||
34 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_result.tpl'; |
||||
35 | include $GLOBALS['xoops']->path('/header.php'); |
||||
36 | |||||
37 | //get module configuration |
||||
38 | /** @var XoopsModuleHandler $moduleHandler */ |
||||
39 | $moduleHandler = xoops_getHandler('module'); |
||||
40 | $module = $moduleHandler->getByDirname($moduleDirName); |
||||
41 | $configHandler = xoops_getHandler('config'); |
||||
42 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||||
0 ignored issues
–
show
The method
getConfigsByCat() does not exist on XoopsObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||
43 | |||||
44 | $f = Request::getString('f', 'pname', 'GET'); |
||||
45 | $q = Request::getString('query', '', 'POST'); |
||||
46 | /* |
||||
47 | if (!isset($_GET['f'])) { |
||||
48 | $f = "pname"; |
||||
49 | } else { |
||||
50 | $f = $_GET['f']; |
||||
51 | } |
||||
52 | |||||
53 | if (isset($_POST['query'])) { |
||||
54 | $q = $_POST['query']; |
||||
55 | } else { |
||||
56 | $q = ''; |
||||
57 | } |
||||
58 | */ |
||||
59 | if ('' === $q < 1 && isset($_POST['query'])) { |
||||
0 ignored issues
–
show
|
|||||
60 | redirect_header('index.php', 3, _MA_PEDIGREE_SEARCH_SHORT); |
||||
61 | } |
||||
62 | |||||
63 | if (!isset($_GET['w'])) { |
||||
64 | $w = '%' . $q . '%'; |
||||
65 | } |
||||
66 | |||||
67 | if (isset($_GET['p'])) { |
||||
68 | $p = $_GET['p']; |
||||
69 | } |
||||
70 | |||||
71 | if (isset($p)) { |
||||
72 | $w = $q; |
||||
73 | } |
||||
74 | |||||
75 | if (isset($_GET['w'])) { |
||||
76 | if ('zero' === $_GET['w'] || '' === $_GET['w'] || '0' === $_GET['w']) { |
||||
77 | $w = '0'; |
||||
78 | } else { |
||||
79 | $w = $_GET['w']; |
||||
80 | } |
||||
81 | } |
||||
82 | if (isset($_GET['l'])) { |
||||
83 | if ('1' == $_GET['l'] || 'LIKE' === $_GET['l']) { |
||||
84 | $l = 'LIKE'; |
||||
85 | } |
||||
86 | } else { |
||||
87 | $l = '='; |
||||
88 | } |
||||
89 | |||||
90 | if (!$_GET['o']) { |
||||
91 | $o = 'pname'; |
||||
92 | } else { |
||||
93 | $o = $_GET['o']; |
||||
94 | } |
||||
95 | |||||
96 | if (!isset($_GET['d'])) { |
||||
97 | $d = 'ASC'; |
||||
98 | } else { |
||||
99 | $d = $_GET['d']; |
||||
100 | } |
||||
101 | |||||
102 | if (!isset($_GET['st'])) { |
||||
103 | $st = 0; |
||||
104 | } else { |
||||
105 | $st = $_GET['st']; |
||||
106 | } |
||||
107 | |||||
108 | $perPage = $moduleConfig['perpage']; |
||||
109 | |||||
110 | //is current user a module admin? |
||||
111 | $modadmin = false; |
||||
112 | $xoopsModule = XoopsModule::getByDirname($moduleDirName); |
||||
113 | if (!empty($GLOBALS['xoopsUser']) && ($GLOBALS['xoopsUser'] instanceof \XoopsUser) |
||||
114 | && $GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { |
||||
115 | $modadmin = true; |
||||
116 | } |
||||
117 | |||||
118 | //count total number of dogs |
||||
119 | $numDog = 'SELECT COUNT(id) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE ' . $f . ' ' . $l . " '" . $w . "'"; |
||||
120 | $numRes = $GLOBALS['xoopsDB']->query($numDog); |
||||
121 | //total number of dogs the query will find |
||||
122 | [$numResults] = $GLOBALS['xoopsDB']->fetchRow($numRes); |
||||
123 | //if nothing is found |
||||
124 | if (0 == $numResults) { |
||||
125 | //just for debug information |
||||
126 | //echo $numDog; |
||||
127 | redirect_header('index.php', 15, strtr(_MA_PEDIGREE_SEARCH_NO, ['[animalTypes]' => $moduleConfig['animalTypes']])); |
||||
128 | } |
||||
129 | //total number of pages |
||||
130 | $numPages = floor($numResults / $perPage) + 1; |
||||
131 | if (($numPages * $perPage) == ($numResults + $perPage)) { |
||||
132 | --$numPages; |
||||
133 | } |
||||
134 | //find current page |
||||
135 | $currentPage = floor($st / $perPage) + 1; |
||||
136 | //create empty pages variable |
||||
137 | $pages = ''; |
||||
138 | |||||
139 | $length = mb_strlen($w); |
||||
140 | if ('%' === mb_substr($w, $length - 1, $length)) { |
||||
141 | $whe = mb_substr($w, 0, $length - 1) . '%25'; |
||||
142 | if (0 === strncmp($whe, '%', 1)) { |
||||
143 | $length = mb_strlen($whe); |
||||
144 | $whe = '%25' . mb_substr($whe, 1, $length); |
||||
145 | } |
||||
146 | } else { |
||||
147 | $whe = $w; |
||||
148 | } |
||||
149 | /* @todo: replace this with standard XOOPS Page Navigation */ |
||||
150 | //create previous button |
||||
151 | if ($numPages > 1) { |
||||
152 | if ($currentPage > 1) { |
||||
153 | $pages .= '<a href="result.php?f=' . $f . '&l=' . $l . '&w=' . $whe . '&o=' . $o . '&d=' . $d . '&st=' . ($st - $perPage) . '">' . _MA_PEDIGREE_PREVIOUS . '</a> '; |
||||
154 | } |
||||
155 | |||||
156 | //create numbers |
||||
157 | for ($x = 1; $x < ($numPages + 1); ++$x) { |
||||
158 | //create line break after 20 number |
||||
159 | if (0 == ($x % 20)) { |
||||
160 | $pages .= '<br>'; |
||||
161 | } |
||||
162 | if ($x != $currentPage) { |
||||
163 | $pages .= '<a href="result.php?f=' . $f . '&l=' . $l . '&w=' . $whe . '&o=' . $o . '&d=' . $d . '&st=' . ($perPage * ($x - 1)) . '">' . $x . '</a> '; |
||||
164 | } else { |
||||
165 | $pages .= '<b>' . $x . '</b>  '; |
||||
166 | } |
||||
167 | } |
||||
168 | } |
||||
169 | //create next button |
||||
170 | if ($numPages > 1) { |
||||
171 | if ($currentPage < $numPages) { |
||||
172 | $pages .= '<a href="result.php?f=' . $f . '&l=' . $l . '&w=' . $whe . '&o=' . $o . '&d=' . $d . '&st=' . ($st + $perPage) . '">' . _MA_PEDIGREE_NEXT . '</a>  '; |
||||
173 | } |
||||
174 | } |
||||
175 | |||||
176 | //query |
||||
177 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE ' . $f . ' ' . $l . " '" . $w . "' ORDER BY " . $o . ' ' . $d . ' LIMIT ' . $st . ', ' . $perPage; |
||||
178 | $result = $GLOBALS['xoopsDB']->query($sql); |
||||
179 | |||||
180 | $animal = new Pedigree\Animal(); |
||||
181 | //test to find out how many user fields there are... |
||||
182 | $fields = $animal->getNumOfFields(); |
||||
183 | $fieldsCount = count($fields); |
||||
184 | $numofcolumns = 1; |
||||
185 | $columns = [['columnname' => 'Name']]; |
||||
186 | foreach ($fields as $i => $iValue) { |
||||
187 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||||
188 | $fieldType = $userField->getSetting('fieldtype'); |
||||
189 | $fieldObject = new $fieldType($userField, $animal); |
||||
190 | //create empty string |
||||
191 | if ($userField->isActive() && $userField->inList()) { |
||||
192 | if ($userField->hasLookup()) { |
||||
193 | $lookupValues = $userField->lookupField($fields[$i]); |
||||
194 | } else { |
||||
195 | $lookupValues = ''; |
||||
196 | } |
||||
197 | /* print_r($lookupValues); //debug information */ |
||||
198 | $columns[] = [ |
||||
199 | 'columnname' => $fieldObject->fieldname, |
||||
200 | 'columnnumber' => $userField->getId(), |
||||
201 | 'lookupval' => $lookupValues, |
||||
202 | ]; |
||||
203 | ++$numofcolumns; |
||||
204 | unset($lookupValues); |
||||
205 | } |
||||
206 | } |
||||
207 | |||||
208 | $pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); |
||||
209 | |||||
210 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||
211 | //reset $gender |
||||
212 | $gender = ''; |
||||
213 | if ($helper->isUserAdmin()) { |
||||
214 | $gender = "<a href=\"dog.php?id={$row['id']}\">{$icons['edit']}</a> <a href=\"delete.php?id={$row['id']}\">{$icons['delete']}</a> "; |
||||
215 | } |
||||
216 | if (Constants::MALE == $row['roft']) { |
||||
0 ignored issues
–
show
The type
Constants was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
217 | $gender .= "<img src=\"" . PEDIGREE_IMAGE_URL . "/male.gif\" alt=\"" . $helper->getConfig('male') . "\" title=\"" . $helper->getConfig('male') . "\">"; |
||||
0 ignored issues
–
show
|
|||||
218 | } else { |
||||
219 | $gender .= "<img src=\"" . PEDIGREE_IMAGE_URL . "/female.gif\" alt=\"" . $helper->getConfig('female') . "\" title=\"" . $helper->getConfig('female') . "\">"; |
||||
220 | } |
||||
221 | |||||
222 | //$camera = ('' != $row['foto']) ? " <img src='" . PEDIGREE_UPLOAD_URL . "/images/dog-icon25.png'>" : ''; |
||||
223 | $camera = ('' !== $row['foto']) ? " <img src=\"" . PEDIGREE_IMAGE_URL . "/camera.png\">" : ''; |
||||
224 | $name = stripslashes($row['pname']) . $camera; |
||||
225 | //empty array |
||||
226 | unset($columnvalue); |
||||
227 | //fill array |
||||
228 | for ($i = 1; $i < $numofcolumns; ++$i) { |
||||
229 | $x = 'user' . $columns[$i]['columnnumber']; |
||||
230 | //echo $x."columnnumber"; |
||||
231 | if (is_array($columns[$i]['lookupval'])) { |
||||
232 | foreach ($columns[$i]['lookupval'] as $key => $keyValue) { |
||||
233 | if ($keyValue['id'] == $row[$x]) { |
||||
234 | //echo "key:".$row['user5']."<br>"; |
||||
235 | $value = $keyValue['value']; |
||||
236 | } |
||||
237 | } |
||||
238 | //debug information |
||||
239 | ///echo $columns[$i]['columnname']."is an array !"; |
||||
240 | } //format value - cant use object because of query count |
||||
241 | elseif (0 === strncmp($row[$x], 'http://', 7)) { |
||||
242 | $value = "<a href='{$row[$x]}'>{$row[$x]}</a>"; |
||||
243 | } else { |
||||
244 | $value = $row[$x]; |
||||
245 | } |
||||
246 | if (isset($value)) { |
||||
247 | $columnvalue[] = ['value' => $value]; |
||||
248 | unset($value); |
||||
249 | } |
||||
250 | } |
||||
251 | $animals[] = [ |
||||
252 | 'id' => $row['id'], |
||||
253 | 'name' => $name, |
||||
254 | 'gender' => $gender, |
||||
255 | 'link' => "<a href='pedigree.php?pedid={$row['id']}'>{$name}</a>", |
||||
256 | 'colour' => '', |
||||
257 | 'number' => '', |
||||
258 | 'usercolumns' => isset($columnvalue) ? $columnvalue : 0, |
||||
259 | ]; |
||||
260 | } |
||||
261 | |||||
262 | //add data to smarty template |
||||
263 | //assign dog |
||||
264 | $GLOBALS['xoopsTpl']->assign([ |
||||
265 | 'dogs' => $animals, |
||||
266 | 'columns' => $columns, |
||||
267 | 'numofcolumns' => $numofcolumns, |
||||
268 | 'tsarray' => Pedigree\Utility::sortTable($numofcolumns), |
||||
269 | ]); |
||||
270 | //assign links |
||||
271 | |||||
272 | //find last shown number |
||||
273 | if (($st + $perPage) > $numResults) { |
||||
274 | $lastshown = $numResults; |
||||
275 | } else { |
||||
276 | $lastshown = $st + $perPage; |
||||
277 | } |
||||
278 | //create string |
||||
279 | $matches = strtr(_MA_PEDIGREE_MATCHES, ['[animalTypes]' => $moduleConfig['animalTypes']]); |
||||
280 | $nummatchstr = "{$numResults}{$matches}" . ($st + 1) . " - {$lastshown} ({$numPages} pages)"; |
||||
281 | $GLOBALS['xoopsTpl']->assign('nummatch', $nummatchstr); |
||||
282 | $GLOBALS['xoopsTpl']->assign('pages', $pages); |
||||
283 | |||||
284 | //comments and footer |
||||
285 | include $GLOBALS['xoops']->path('footer.php'); |
||||
286 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: