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 | * @copyright Copyright (c) 2001-2019 {@link https://xoops.org XOOPS Project} |
||||||
18 | * @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
||||||
19 | * @author XOOPS Module Development Team |
||||||
20 | */ |
||||||
21 | |||||||
22 | use Xmf\Request; |
||||||
0 ignored issues
–
show
|
|||||||
23 | use XoopsModules\Pedigree; |
||||||
24 | use XoopsModules\Pedigree\Constants; |
||||||
25 | |||||||
26 | require_once __DIR__ . '/header.php'; |
||||||
27 | /** @var XoopsModules\Pedigree\Helper $helper */ |
||||||
28 | $helper->loadLanguage('main'); |
||||||
29 | //xoops_load('Pedigree\Animal', $moduleDirName); |
||||||
30 | |||||||
31 | // Include any common code for this module. |
||||||
32 | require_once $helper->path('include/common.php'); |
||||||
33 | |||||||
34 | /* |
||||||
35 | // Get all HTTP post or get parameters into global variables that are prefixed with "param_" |
||||||
36 | //import_request_variables("gp", "param_"); |
||||||
37 | extract($_GET, EXTR_PREFIX_ALL, "param"); |
||||||
38 | extract($_POST, EXTR_PREFIX_ALL, "param"); |
||||||
39 | */ |
||||||
40 | |||||||
41 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_sel.tpl'; |
||||||
42 | include $GLOBALS['xoops']->path('/header.php'); |
||||||
43 | |||||||
44 | $st = Request::getInt('st', 0, 'GET'); |
||||||
45 | $gend = Request::getInt('gend', Constants::MALE, 'GET'); |
||||||
46 | $curval = Request::getInt('curval', 0, 'GET'); |
||||||
47 | |||||||
48 | /* @todo: default value of 'a' assumes english, this should be defined in language file */ |
||||||
49 | $letter = Request::getString('letter', 'A', 'GET'); |
||||||
50 | |||||||
51 | $confPerPage = (int)$helper->getConfig('perpage', Constants::DEFAULT_PER_PAGE); |
||||||
52 | $perPage = (int)$confPerPage > 0 ? (int)$confPerPage : Constants::DEFAULT_PER_PAGE; |
||||||
53 | |||||||
54 | $GLOBALS['xoopsTpl']->assign('page_title', _MI_PEDIGREE_TITLE); |
||||||
55 | |||||||
56 | //count total number of dogs |
||||||
57 | $treeHandler = $helper->getHandler('Tree'); |
||||||
58 | $criteria = new \CriteriaCompo('roft', $gend); |
||||||
59 | $criteria->add(new \Criteria('pname', "{$letter}%"), 'LIKE'); |
||||||
60 | $treeCount = $treeHandler->getCount($criteria); |
||||||
0 ignored issues
–
show
$criteria of type CriteriaCompo is incompatible with the type CriteriaElement|null expected by parameter $criteria of XoopsModules\Pedigree\TreeHandler::getCount() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
61 | |||||||
62 | //total number of pages |
||||||
63 | $numPages = floor($treeCount / $perPage) + 1; |
||||||
64 | if (($numPages * $perPage) == ($treeCount + $perPage)) { |
||||||
65 | --$numPages; |
||||||
66 | } |
||||||
67 | //find current page |
||||||
68 | $currentPage = floor($st / $perPage) + 1; |
||||||
69 | /* |
||||||
70 | $numDog = 'SELECT id FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE pname LIKE '{$letter}%' AND roft = '{$gend}'"; |
||||||
71 | $numRes = $GLOBALS['xoopsDB']->query($numDog); |
||||||
72 | //total number of dogs the query will find |
||||||
73 | $numResults = $GLOBALS['xoopsDB']->getRowsNum($numRes); |
||||||
74 | //total number of pages |
||||||
75 | $numPages = floor($numResults / $perPage) + 1; |
||||||
76 | if (($numPages * $perPage) == ($numResults + $perPage)) { |
||||||
77 | --$numPages; |
||||||
78 | } |
||||||
79 | //find current page |
||||||
80 | $currentPage = floor($st / $perPage) + 1; |
||||||
81 | */ |
||||||
82 | /* @todo: change this to use letters() from mylinks or similar module - this routine assumes english */ |
||||||
83 | //create alphabet |
||||||
84 | $pages = ''; |
||||||
85 | for ($i = 65; $i <= 90; ++$i) { |
||||||
86 | if ($letter == chr($i)) { |
||||||
87 | $pages .= "<b><a href='seldog.php?gend={$gend}&curval={$curval}&letter=" . chr($i) . "'>" . chr($i) . '</a></b> '; |
||||||
88 | } else { |
||||||
89 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter=" . chr($i) . "'>" . chr($i) . '</a> '; |
||||||
90 | } |
||||||
91 | } |
||||||
92 | $pages .= '- '; |
||||||
93 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter=Ã…\">Ã…</a> "; |
||||||
94 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter=Ö\">Ö</a> "; |
||||||
95 | //create linebreak |
||||||
96 | $pages .= '<br>'; |
||||||
97 | //create previous button |
||||||
98 | if (($numPages > 1) && ($currentPage > 1)) { |
||||||
99 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter={$letter}&st=" . ($st - $perPage) . "'>" . _MA_PEDIGREE_PREVIOUS . '</a>  '; |
||||||
100 | } |
||||||
101 | //create numbers |
||||||
102 | for ($x = 1; $x < ($numPages + 1); ++$x) { |
||||||
103 | //create line break after 20 number |
||||||
104 | if (0 == ($x % 20)) { |
||||||
105 | $pages .= '<br>'; |
||||||
106 | } |
||||||
107 | if ($x != $currentPage) { |
||||||
108 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter={$letter}&st=" . ($perPage * ($x - 1)) . "'>{$x}</a>  "; |
||||||
109 | } else { |
||||||
110 | $pages .= "{$x}  "; |
||||||
111 | } |
||||||
112 | } |
||||||
113 | //create next button |
||||||
114 | if (($numPages > 1) && ($currentPage < $numPages)) { |
||||||
115 | $pages .= "<a href='seldog.php?gend={$gend}&curval={$curval}&letter={$letter}&st=" . ($st + $perPage) . "'>" . _MA_PEDIGREE_NEXT . '</a>  '; |
||||||
116 | } |
||||||
117 | |||||||
118 | //query |
||||||
119 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE pname LIKE '{$letter}%' AND roft = '{$gend}' ORDER BY pname LIMIT {$st}, {$perPage}"; |
||||||
120 | $result = $GLOBALS['xoopsDB']->query($sql); |
||||||
121 | |||||||
122 | $animal = new Pedigree\Animal(); |
||||||
123 | //test to find out how many user fields there are... |
||||||
124 | $fields = $animal->getNumOfFields(); |
||||||
125 | $fieldsCount = count($fields); |
||||||
126 | $numofcolumns = 1; |
||||||
127 | //@todo move hard coded language string to language file |
||||||
128 | $columns[] = ['columnname' => 'Name']; |
||||||
129 | foreach ($fields as $i => $iValue) { |
||||||
130 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||||||
131 | $fieldType = $userField->getSetting('fieldtype'); |
||||||
132 | $fieldObj = new $fieldType($userField, $animal); |
||||||
133 | //create empty string |
||||||
134 | if ($userField->isActive() && $userField->inList()) { |
||||||
135 | if ($userField->hasLookup()) { |
||||||
136 | $lookupValues = $userField->lookupField($fields[$i]); |
||||||
137 | //debug information |
||||||
138 | //print_r($lookupValues); |
||||||
139 | } else { |
||||||
140 | $lookupValues = ''; |
||||||
141 | } |
||||||
142 | $columns[] = [ |
||||||
143 | 'columnname' => $fieldObj->fieldname, |
||||||
144 | 'columnnumber' => $userField->getId(), |
||||||
145 | 'lookupval' => $lookupValues, |
||||||
146 | ]; |
||||||
147 | ++$numofcolumns; |
||||||
148 | unset($lookupValues); |
||||||
149 | } |
||||||
150 | } |
||||||
151 | |||||||
152 | $empty = array_fill(0, $numofcolumns, ['value' => '']); |
||||||
153 | /* |
||||||
154 | for ($i = 1; $i < $numofcolumns; ++$i) { |
||||||
155 | $empty[] = array('value' => ""); |
||||||
156 | } |
||||||
157 | */ |
||||||
158 | if (Constants::MALE === $gend) { |
||||||
159 | $dogs[] = [ |
||||||
160 | 'id' => '0', |
||||||
161 | 'name' => '', |
||||||
162 | 'gender' => '', |
||||||
163 | 'link' => '<a href="' . $helper->url("updatepage.php?gend=" . Constants::MALE . "&curval={$curval}&thisid=0") . '">' . strtr(_MA_PEDIGREE_ADD_SIREUNKNOWN, ['[father]' => $helper->getConfig('father')]) . '</a>', |
||||||
164 | 'colour' => '', |
||||||
165 | 'number' => '', |
||||||
166 | 'usercolumns' => $empty, |
||||||
167 | ]; |
||||||
168 | } else { |
||||||
169 | $dogs[] = [ |
||||||
170 | 'id' => '0', |
||||||
171 | 'name' => '', |
||||||
172 | 'gender' => '', |
||||||
173 | 'link' => '<a href="' . $helper->url("updatepage.php?gend=" . Constants::FEMALE . "&curval={$curval}&thisid=0") . '">' . strtr(_MA_PEDIGREE_ADD_DAMUNKNOWN, ['[mother]' => $helper->getConfig('mother')]) . '</a>', |
||||||
174 | 'colour' => '', |
||||||
175 | 'number' => '', |
||||||
176 | 'usercolumns' => $empty, |
||||||
177 | ]; |
||||||
178 | } |
||||||
179 | |||||||
180 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
181 | //create picture information |
||||||
182 | $camera = ('' != $row['foto']) ? " <img src=\"" . PEDIGREE_IMAGE_URL . "/camera.png\">" : ''; |
||||||
0 ignored issues
–
show
|
|||||||
183 | $name = stripslashes($row['pname']) . $camera; |
||||||
184 | //empty array |
||||||
185 | unset($columnvalue); |
||||||
186 | //fill array |
||||||
187 | for ($i = 1; $i < $numofcolumns; ++$i) { |
||||||
188 | $x = 'user' . $columns[$i]['columnnumber']; |
||||||
189 | if (is_array($columns[$i]['lookupval'])) { |
||||||
190 | foreach ($columns[$i]['lookupval'] as $key => $keyValue) { |
||||||
191 | if ($key == $row[$x]) { |
||||||
192 | $value = $keyValue['value']; |
||||||
193 | } |
||||||
194 | } |
||||||
195 | //debug information |
||||||
196 | ///echo $columns[$i]['columnname']."is an array !"; |
||||||
197 | } //format value - cant use object because of query count |
||||||
198 | elseif (0 === strncmp($row[$x], 'http://', 7)) { |
||||||
199 | $value = "<a href='{$row[$x]}'>{$row[$x]}</a>"; |
||||||
200 | } else { |
||||||
201 | $value = $row[$x]; |
||||||
202 | } |
||||||
203 | $columnvalue[] = ['value' => $value]; |
||||||
204 | } |
||||||
205 | if (Constants::MALE == $gend) { |
||||||
206 | $dogs[] = [ |
||||||
207 | 'id' => $row['id'], |
||||||
208 | 'name' => $name, |
||||||
209 | 'gender' => "<img src=\"" . PEDIGREE_IMAGE_URL . "/male.gif\" alt=\"" . $helper->getConfig('male') . "\" title=\"" . $helper->getConfig('male') . "\">", |
||||||
210 | 'link' => "<a href='updatepage.php?gend={$gend}&curval={$curval}&thisid={$row['id']}'>{$name}</a>", |
||||||
211 | 'colour' => '', |
||||||
212 | 'number' => '', |
||||||
213 | 'usercolumns' => isset($columnvalue) ?: [], |
||||||
214 | ]; |
||||||
215 | } else { |
||||||
216 | $dogs[] = [ |
||||||
217 | 'id' => $row['id'], |
||||||
218 | 'name' => $name, |
||||||
219 | 'gender' => "<img src=\"" . PEDIGREE_IMAGE_URL . "/female.gif\" alt=\"" . $helper->getConfig('female') . "\" title=\"" . $helper->getConfig('female') . "\">", |
||||||
220 | 'link' => "<a href='updatepage.php?gend={$gend}&curval={$curval}&thisid={$row['id']}'>{$name}</a>", |
||||||
221 | 'colour' => '', |
||||||
222 | 'number' => '', |
||||||
223 | 'usercolumns' => isset($columnvalue) ?: [], |
||||||
224 | ]; |
||||||
225 | } |
||||||
226 | } |
||||||
227 | |||||||
228 | //add data to smarty template |
||||||
229 | //assign dog |
||||||
230 | $GLOBALS['xoopsTpl']->assign([ |
||||||
231 | 'dogs' => $dogs, |
||||||
232 | 'columns' => $columns, |
||||||
233 | 'numofcolumns' => $numofcolumns, |
||||||
234 | 'tsarray' => Pedigree\Utility::sortTable($numofcolumns), |
||||||
235 | ]); |
||||||
236 | //add data to smarty template |
||||||
237 | if (0 == $gend) { |
||||||
238 | $selTtlParent = strtr(_MA_PEDIGREE_FLD_FATH, ['[father]' => $helper->getConfig('father')]); |
||||||
239 | } else { |
||||||
240 | $selTtlParent = strtr(_MA_PEDIGREE_FLD_MOTH, ['[mother]' => $helper->getConfig('mother')]); |
||||||
241 | } |
||||||
242 | $seltitle = _MA_PEDIGREE_SEL . $selTtlParent . _MA_PEDIGREE_FROM . Pedigree\Utility::getName($curval); |
||||||
243 | |||||||
244 | $GLOBALS['xoopsTpl']->assign('seltitle', $seltitle); |
||||||
245 | |||||||
246 | //find last shown number |
||||||
247 | $lastshown = (($st + $perPage) > $numResults) ? $numResults : $st + $perPage; |
||||||
248 | |||||||
249 | //create string |
||||||
250 | /* @todo: move hard coded language string to language files */ |
||||||
251 | $matches = strtr(_MA_PEDIGREE_MATCHES, ['[animalTypes]' => $helper->getConfig('animalTypes')]); |
||||||
252 | $nummatchstr = "{$numResults}{$matches}" . ($st + 1) . " - {$lastshown} ({$numPages} pages)"; |
||||||
253 | $GLOBALS['xoopsTpl']->assign([ |
||||||
254 | 'nummatch' => $nummatchstr, |
||||||
255 | 'pages' => $pages, |
||||||
256 | 'curval' => $curval, |
||||||
257 | ]); |
||||||
258 | |||||||
259 | //mb ========= MOTHER LETTERS=============================== |
||||||
260 | $roft = $gend; |
||||||
261 | //$criteria = $helper->getHandler('Tree')->getActiveCriteria($roft); |
||||||
262 | $activeObject = 'Tree'; |
||||||
263 | $name = 'pname'; |
||||||
264 | $number1 = '1'; |
||||||
265 | $number2 = '0'; |
||||||
266 | $link = "seldog.php?gend={$gend}&curval={$curval}&letter="; |
||||||
267 | |||||||
268 | $criteria = $helper->getHandler('Tree')->getActiveCriteria($roft); |
||||||
269 | $criteria->setGroupby('UPPER(LEFT(' . $name . ',1))'); |
||||||
0 ignored issues
–
show
The method
setGroupby() does not exist on CriteriaCompo .
(
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. ![]() |
|||||||
270 | |||||||
271 | $motherArray['letters'] = Pedigree\Utility::lettersChoice($helper, $activeObject, $criteria, $name, $link); |
||||||
272 | //$catarray['toolbar'] = pedigree_toolbar(); |
||||||
273 | $xoopsTpl->assign('motherArray', $motherArray); |
||||||
274 | |||||||
275 | //mb ======================================== |
||||||
276 | |||||||
277 | include $GLOBALS['xoops']->path('footer.php'); |
||||||
278 |
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: