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 | namespace XoopsModules\Pedigree; |
||||||
4 | |||||||
5 | $moduleDirName = \basename(\dirname(__DIR__)); |
||||||
6 | require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->dirname() . '/include/class_field.php'); |
||||||
7 | require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->dirname() . '/include/config.php'); |
||||||
8 | \xoops_load('Pedigree\Animal', $moduleDirName); |
||||||
9 | |||||||
10 | //get module configuration |
||||||
11 | /** @var \XoopsModuleHandler $moduleHandler */ |
||||||
12 | $moduleHandler = \xoops_getHandler('module'); |
||||||
13 | $module = $moduleHandler->getByDirname($moduleDirName); |
||||||
14 | $configHandler = \xoops_getHandler('config'); |
||||||
15 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
16 | |||||||
17 | /** |
||||||
18 | * Class Pedigree\Utility |
||||||
19 | */ |
||||||
20 | class pedigreeUtilities0 |
||||||
21 | { |
||||||
22 | /** |
||||||
23 | * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
||||||
24 | * |
||||||
25 | * @param string $folder The full path of the directory to check |
||||||
26 | */ |
||||||
27 | public static function prepareFolder($folder) |
||||||
28 | { |
||||||
29 | // $filteredFolder = XoopsFilterInput::clean($folder, 'PATH'); |
||||||
30 | if (!\is_dir($folder)) { |
||||||
31 | \mkdir($folder); |
||||||
32 | file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
||||||
33 | } |
||||||
34 | // chmod($filteredFolder, 0777); |
||||||
35 | } |
||||||
36 | |||||||
37 | /** |
||||||
38 | * @param $columncount |
||||||
39 | * |
||||||
40 | * @return string |
||||||
41 | */ |
||||||
42 | public static function sortTable($columncount) |
||||||
43 | { |
||||||
44 | $ttemp = ''; |
||||||
45 | if ($columncount > 1) { |
||||||
46 | for ($t = 1; $t < $columncount; ++$t) { |
||||||
47 | $ttemp .= "'S',"; |
||||||
48 | } |
||||||
49 | $tsarray = "initSortTable('Result', Array({$ttemp}'S'));"; |
||||||
50 | } else { |
||||||
51 | $tsarray = "initSortTable('Result',Array('S'));"; |
||||||
52 | } |
||||||
53 | |||||||
54 | return $tsarray; |
||||||
55 | } |
||||||
56 | |||||||
57 | /** |
||||||
58 | * @param $num |
||||||
59 | * |
||||||
60 | * @return string |
||||||
61 | */ |
||||||
62 | public static function uploadPicture($num) |
||||||
63 | { |
||||||
64 | $max_imgsize = $GLOBALS['xoopsModuleConfig']['maxfilesize']; //1024000; |
||||||
65 | $max_imgwidth = $GLOBALS['xoopsModuleConfig']['maximgwidth']; //1500; |
||||||
66 | $max_imgheight = $GLOBALS['xoopsModuleConfig']['maximgheight']; //1000; |
||||||
67 | $allowed_mimetypes = ['image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png']; |
||||||
68 | // $img_dir = XOOPS_ROOT_PATH . "/modules/" . $GLOBALS['xoopsModule']->dirname() . "/images" ; |
||||||
69 | $img_dir = $GLOBALS['xoopsModuleConfig']['uploaddir'] . '/images'; |
||||||
70 | require_once $GLOBALS['xoops']->path('class/uploader.php'); |
||||||
71 | $field = $_POST['xoops_upload_file'][$num]; |
||||||
72 | if (!empty($field) || '' != $field) { |
||||||
73 | $uploader = new \XoopsMediaUploader($img_dir, $allowed_mimetypes, $max_imgsize, $max_imgwidth, $max_imgheight); |
||||||
74 | $uploader->setPrefix('img'); |
||||||
75 | if ($uploader->fetchMedia($field) && $uploader->upload()) { |
||||||
76 | $photo = $uploader->getSavedFileName(); |
||||||
77 | } else { |
||||||
78 | echo $uploader->getErrors(); |
||||||
79 | } |
||||||
80 | static::createThumbs($photo); |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
81 | |||||||
82 | return $photo; |
||||||
83 | } |
||||||
84 | } |
||||||
85 | |||||||
86 | /** |
||||||
87 | * @param $filename |
||||||
88 | */ |
||||||
89 | public static function createThumbs($filename) |
||||||
90 | { |
||||||
91 | /* |
||||||
92 | require_once __DIR__ . '/phpthumb/phpthumb.class.php'; |
||||||
93 | $thumbnail_widths = array(150, 400); |
||||||
94 | foreach ($thumbnail_widths as $thumbnail_width) { |
||||||
95 | $phpThumb = new phpThumb(); |
||||||
96 | // set data |
||||||
97 | $phpThumb->setSourceFilename('images/' . $filename); |
||||||
98 | $phpThumb->w = $thumbnail_width; |
||||||
99 | $phpThumb->config_output_format = 'jpeg'; |
||||||
100 | // generate & output thumbnail |
||||||
101 | $output_filename = 'images/thumbnails/' . basename($filename) . '_' . $thumbnail_width . '.' . $phpThumb->config_output_format; |
||||||
102 | if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it! |
||||||
103 | if ($output_filename) { |
||||||
104 | if ($phpThumb->RenderToFile($output_filename)) { |
||||||
105 | // do something on success |
||||||
106 | //echo 'Successfully rendered:<br><img src="'.$output_filename.'">'; |
||||||
107 | } else { |
||||||
108 | echo 'Failed (size=' . $thumbnail_width . '):<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>'; |
||||||
109 | } |
||||||
110 | } |
||||||
111 | } else { |
||||||
112 | echo 'Failed (size=' . $thumbnail_width . '):<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>'; |
||||||
113 | } |
||||||
114 | unset($phpThumb); |
||||||
115 | } |
||||||
116 | |||||||
117 | return true; |
||||||
118 | |||||||
119 | */ |
||||||
120 | |||||||
121 | // load the image |
||||||
122 | require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->dirname() . '/library/Zebra_Image.php'); |
||||||
123 | $thumbnail_widths = [150, 400]; |
||||||
124 | |||||||
125 | // indicate a target image |
||||||
126 | // note that there's no extra property to set in order to specify the target |
||||||
127 | // image's type -simply by writing '.jpg' as extension will instruct the script |
||||||
128 | // to create a 'jpg' file |
||||||
129 | $config_output_format = 'jpeg'; |
||||||
130 | |||||||
131 | // create a new instance of the class |
||||||
132 | $image = new \Zebra_Image(); |
||||||
133 | // indicate a source image (a GIF, PNG or JPEG file) |
||||||
134 | $image->source_path = PEDIGREE_UPLOAD_PATH . "/images/{$filename}"; |
||||||
0 ignored issues
–
show
|
|||||||
135 | |||||||
136 | foreach ($thumbnail_widths as $thumbnail_width) { |
||||||
137 | // generate & output thumbnail |
||||||
138 | $output_filename = PEDIGREE_UPLOAD_PATH . '/images/thumbnails/' . \basename($filename) . "_{$thumbnail_width}.{$config_output_format}"; |
||||||
139 | $image->target_path = $output_filename; |
||||||
140 | // since in this example we're going to have a jpeg file, let's set the output |
||||||
141 | // image's quality |
||||||
142 | $image->jpeg_quality = 100; |
||||||
143 | // some additional properties that can be set |
||||||
144 | // read about them in the documentation |
||||||
145 | $image->preserve_aspect_ratio = true; |
||||||
146 | $image->enlarge_smaller_images = true; |
||||||
147 | $image->preserve_time = true; |
||||||
148 | |||||||
149 | // resize the image to exactly 100x100 pixels by using the "crop from center" method |
||||||
150 | // (read more in the overview section or in the documentation) |
||||||
151 | // and if there is an error, check what the error is about |
||||||
152 | if (!$image->resize($thumbnail_width, 0)) { |
||||||
153 | // if there was an error, let's see what the error is about |
||||||
154 | switch ($image->error) { |
||||||
155 | case 1: |
||||||
156 | echo 'Source file could not be found!'; |
||||||
157 | break; |
||||||
158 | case 2: |
||||||
159 | echo 'Source file is not readable!'; |
||||||
160 | break; |
||||||
161 | case 3: |
||||||
162 | echo 'Could not write target file!'; |
||||||
163 | break; |
||||||
164 | case 4: |
||||||
165 | echo 'Unsupported source file format!'; |
||||||
166 | break; |
||||||
167 | case 5: |
||||||
168 | echo 'Unsupported target file format!'; |
||||||
169 | break; |
||||||
170 | case 6: |
||||||
171 | echo 'GD library version does not support target file format!'; |
||||||
172 | break; |
||||||
173 | case 7: |
||||||
174 | echo 'GD library is not installed!'; |
||||||
175 | break; |
||||||
176 | case 8: |
||||||
177 | echo '"chmod" command is disabled via configuration!'; |
||||||
178 | break; |
||||||
179 | } |
||||||
180 | // if no errors |
||||||
181 | } else { |
||||||
182 | echo 'Success!'; |
||||||
183 | } |
||||||
184 | /* |
||||||
185 | if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it! |
||||||
186 | if ($output_filename) { |
||||||
187 | if ($phpThumb->RenderToFile($output_filename)) { |
||||||
188 | // do something on success |
||||||
189 | //echo 'Successfully rendered:<br><img src="'.$output_filename.'">'; |
||||||
190 | } else { |
||||||
191 | echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>'; |
||||||
192 | } |
||||||
193 | } |
||||||
194 | } else { |
||||||
195 | echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>'; |
||||||
196 | } |
||||||
197 | */ |
||||||
198 | } |
||||||
199 | |||||||
200 | unset($image); |
||||||
201 | } |
||||||
202 | |||||||
203 | /** |
||||||
204 | * @param $string |
||||||
205 | * |
||||||
206 | * @return string |
||||||
207 | */ |
||||||
208 | public static function unHtmlEntities($string) |
||||||
209 | { |
||||||
210 | $trans_tbl = \get_html_translation_table(\HTML_ENTITIES); |
||||||
211 | $trans_tbl = \array_flip($trans_tbl); |
||||||
212 | |||||||
213 | return strtr($string, $trans_tbl); |
||||||
214 | } |
||||||
215 | |||||||
216 | /** |
||||||
217 | * @param $oid |
||||||
218 | * @param $gender |
||||||
219 | */ |
||||||
220 | public static function pups($oid, $gender) |
||||||
221 | { |
||||||
222 | global $numofcolumns, $numMatch, $pages, $columns, $dogs; |
||||||
223 | $content = ''; |
||||||
0 ignored issues
–
show
|
|||||||
224 | if (0 == $gender) { |
||||||
225 | $sqlQuery = 'SELECT d.id AS d_id, d.pname AS d_pname, d.roft AS d_roft, d.* FROM ' |
||||||
226 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||||||
227 | . ' d LEFT JOIN ' |
||||||
228 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||||||
229 | . ' f ON d.father = f.id LEFT JOIN ' |
||||||
230 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||||||
231 | . ' m ON d.mother = m.id WHERE d.father=' |
||||||
232 | . $oid |
||||||
233 | . ' ORDER BY d.pname'; |
||||||
234 | } else { |
||||||
235 | $sqlQuery = 'SELECT d.id AS d_id, d.pname AS d_pname, d.roft AS d_roft, d.* FROM ' |
||||||
236 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||||||
237 | . ' d LEFT JOIN ' |
||||||
238 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||||||
239 | . ' f ON d.father = f.id LEFT JOIN ' |
||||||
240 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||||||
241 | . ' m ON d.mother = m.id WHERE d.mother=' |
||||||
242 | . $oid |
||||||
243 | . ' ORDER BY d.pname'; |
||||||
244 | } |
||||||
245 | $queryResult = $GLOBALS['xoopsDB']->query($sqlQuery); |
||||||
246 | $numMatch = $GLOBALS['xoopsDB']->getRowsNum($queryResult); |
||||||
247 | |||||||
248 | $animal = new Pedigree\Animal(); |
||||||
0 ignored issues
–
show
The type
XoopsModules\Pedigree\Pedigree\Animal 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 ![]() |
|||||||
249 | //test to find out how many user fields there are... |
||||||
250 | $fields = $animal->getNumOfFields(); |
||||||
251 | $numofcolumns = 1; |
||||||
252 | $columns[] = ['columnname' => 'Name']; |
||||||
253 | for ($i = 0, $iMax = \count($fields); $i < $iMax; ++$i) { |
||||||
254 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||||||
0 ignored issues
–
show
The type
XoopsModules\Pedigree\Pedigree\Field 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 ![]() |
|||||||
255 | $fieldType = $userField->getSetting('FieldType'); |
||||||
256 | $fieldObject = new $fieldType($userField, $animal); |
||||||
257 | //create empty string |
||||||
258 | $lookupValues = ''; |
||||||
259 | if ($userField->isActive() && $userField->inList()) { |
||||||
260 | if ($userField->hasLookup()) { |
||||||
261 | $lookupValues = $userField->lookupField($fields[$i]); |
||||||
262 | //debug information |
||||||
263 | //print_r($lookupValues); |
||||||
264 | } |
||||||
265 | $columns[] = [ |
||||||
266 | 'columnname' => $fieldObject->fieldname, |
||||||
267 | 'columnnumber' => $userField->getId(), |
||||||
268 | 'lookupval' => $lookupValues, |
||||||
269 | ]; |
||||||
270 | ++$numofcolumns; |
||||||
271 | unset($lookupValues); |
||||||
272 | } |
||||||
273 | } |
||||||
274 | |||||||
275 | while (false !== ($rowResult = $GLOBALS['xoopsDB']->fetchArray($queryResult))) { |
||||||
276 | if ('0' == $rowResult['d_roft']) { |
||||||
277 | $gender = '<img src="assets/images/male.gif">'; |
||||||
278 | } else { |
||||||
279 | $gender = '<img src="assets/images/female.gif">'; |
||||||
280 | } |
||||||
281 | $name = \stripslashes($rowResult['d_pname']); |
||||||
282 | //empty array |
||||||
283 | unset($columnvalue); |
||||||
284 | //fill array |
||||||
285 | for ($i = 1; $i < $numofcolumns; ++$i) { |
||||||
286 | $x = $columns[$i]['columnnumber']; |
||||||
287 | if (\is_array($columns[$i]['lookupval'])) { |
||||||
288 | foreach ($columns[$i]['lookupval'] as $key => $keyValue) { |
||||||
289 | if ($keyValue['id'] == $rowResult['user' . $x]) { |
||||||
290 | $value = $keyValue['value']; |
||||||
291 | } |
||||||
292 | } |
||||||
293 | //debug information |
||||||
294 | ///echo $columns[$i]['columnname']."is an array !"; |
||||||
295 | } //format value - cant use object because of query count |
||||||
296 | elseif (0 === \strncmp($rowResult['user' . $x], 'http://', 7)) { |
||||||
297 | $value = '<a href="' . $rowResult['user' . $x] . '">' . $rowResult['user' . $x] . '</a>'; |
||||||
298 | } else { |
||||||
299 | $value = $rowResult['user' . $x]; |
||||||
300 | } |
||||||
301 | $columnvalue[] = ['value' => $value]; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
302 | } |
||||||
303 | $dogs[] = [ |
||||||
304 | 'id' => $rowResult['d_id'], |
||||||
305 | 'name' => $name, |
||||||
306 | 'gender' => $gender, |
||||||
307 | 'link' => '<a href="dog.php?id=' . $rowResult['d_id'] . '">' . $name . '</a>', |
||||||
308 | 'colour' => '', |
||||||
309 | 'number' => '', |
||||||
310 | 'usercolumns' => $columnvalue, |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
311 | ]; |
||||||
312 | } |
||||||
313 | |||||||
314 | return null; |
||||||
315 | } |
||||||
316 | |||||||
317 | /** |
||||||
318 | * @param $oid |
||||||
319 | * @param $pa |
||||||
320 | * @param $ma |
||||||
321 | */ |
||||||
322 | public static function bas($oid, $pa, $ma) |
||||||
323 | { |
||||||
324 | global $numofcolumns1, $nummatch1, $pages1, $columns1, $dogs1; |
||||||
325 | if ('0' == $pa && '0' == $ma) { |
||||||
326 | $sqlQuery = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE father = ' . $pa . ' AND mother = ' . $ma . ' AND id != ' . $oid . " AND father != '0' AND mother !='0' ORDER BY pname"; |
||||||
327 | } else { |
||||||
328 | $sqlQuery = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE father = ' . $pa . ' AND mother = ' . $ma . ' AND id != ' . $oid . ' ORDER BY pname'; |
||||||
329 | } |
||||||
330 | $queryResult = $GLOBALS['xoopsDB']->query($sqlQuery); |
||||||
331 | $nummatch1 = $GLOBALS['xoopsDB']->getRowsNum($queryResult); |
||||||
332 | |||||||
333 | $animal = new Pedigree\Animal(); |
||||||
334 | //test to find out how many user fields there are... |
||||||
335 | $fields = $animal->getNumOfFields(); |
||||||
336 | $numofcolumns1 = 1; |
||||||
337 | $columns1[] = ['columnname' => 'Name']; |
||||||
338 | for ($i = 0, $iMax = \count($fields); $i < $iMax; ++$i) { |
||||||
339 | $userField = new Field($fields[$i], $animal->getConfig()); |
||||||
340 | $fieldType = $userField->getSetting('FieldType'); |
||||||
341 | $fieldObject = new $fieldType($userField, $animal); |
||||||
342 | //create empty string |
||||||
343 | $lookupValues = ''; |
||||||
344 | if ($userField->isActive() && $userField->inList()) { |
||||||
345 | if ($userField->hasLookup()) { |
||||||
346 | $lookupValues = $userField->lookupField($fields[$i]); |
||||||
347 | //debug information |
||||||
348 | //print_r($lookupValues); |
||||||
349 | } |
||||||
350 | $columns1[] = [ |
||||||
351 | 'columnname' => $fieldObject->fieldname, |
||||||
352 | 'columnnumber' => $userField->getId(), |
||||||
353 | 'lookupval' => $lookupValues, |
||||||
354 | ]; |
||||||
355 | ++$numofcolumns1; |
||||||
356 | unset($lookupValues); |
||||||
357 | } |
||||||
358 | } |
||||||
359 | |||||||
360 | while (false !== ($rowResult = $GLOBALS['xoopsDB']->fetchArray($queryResult))) { |
||||||
361 | if (0 == $rowResult['roft']) { |
||||||
362 | $gender = "<img src='assets/images/male.gif'>"; |
||||||
363 | } else { |
||||||
364 | $gender = "<img src='assets/images/female.gif'>"; |
||||||
365 | } |
||||||
366 | $name = \stripslashes($rowResult['pname']); |
||||||
367 | //empty array |
||||||
368 | // unset($columnvalue1); |
||||||
369 | $columnvalue1 = []; |
||||||
370 | //fill array |
||||||
371 | for ($i = 1; $i < $numofcolumns1; ++$i) { |
||||||
372 | $x = $columns1[$i]['columnnumber']; |
||||||
373 | if (\is_array($columns1[$i]['lookupval'])) { |
||||||
374 | foreach ($columns1[$i]['lookupval'] as $key => $keyValue) { |
||||||
375 | if ($keyValue['id'] == $rowResult['user' . $x]) { |
||||||
376 | $value = $keyValue['value']; |
||||||
377 | } |
||||||
378 | } |
||||||
379 | //debug information |
||||||
380 | ///echo $columns[$i]['columnname']."is an array !"; |
||||||
381 | } //format value - cant use object because of query count |
||||||
382 | elseif (0 === \strncmp($rowResult['user' . $x], 'http://', 7)) { |
||||||
383 | $value = '<a href="' . $rowResult['user' . $x] . '">' . $rowResult['user' . $x] . '</a>'; |
||||||
384 | } else { |
||||||
385 | $value = $rowResult['user' . $x]; |
||||||
386 | } |
||||||
387 | $columnvalue1[] = ['value' => $value]; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
388 | } |
||||||
389 | $dogs1[] = [ |
||||||
390 | 'id' => $rowResult['id'], |
||||||
391 | 'name' => $name, |
||||||
392 | 'gender' => $gender, |
||||||
393 | 'link' => '<a href="dog.php?id=' . $rowResult['id'] . '">' . $name . '</a>', |
||||||
394 | 'colour' => '', |
||||||
395 | 'number' => '', |
||||||
396 | 'usercolumns' => $columnvalue1, |
||||||
397 | ]; |
||||||
398 | } |
||||||
399 | |||||||
400 | return null; |
||||||
401 | } |
||||||
402 | |||||||
403 | /** |
||||||
404 | * @param $oid |
||||||
405 | * @param $breeder |
||||||
406 | * |
||||||
407 | * @return string |
||||||
408 | */ |
||||||
409 | public static function breederof($oid, $breeder) |
||||||
410 | { |
||||||
411 | $content = ''; |
||||||
412 | |||||||
413 | if (0 == $breeder) { |
||||||
414 | $sqlQuery = 'SELECT id, pname, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE id_owner = '" . $oid . "' ORDER BY pname"; |
||||||
415 | } else { |
||||||
416 | $sqlQuery = 'SELECT id, pname, roft FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE id_breeder = '" . $oid . "' ORDER BY pname"; |
||||||
417 | } |
||||||
418 | $queryResult = $GLOBALS['xoopsDB']->query($sqlQuery); |
||||||
419 | while (false !== ($rowResult = $GLOBALS['xoopsDB']->fetchArray($queryResult))) { |
||||||
420 | if ('0' == $rowResult['roft']) { |
||||||
421 | $gender = '<img src="assets/images/male.gif">'; |
||||||
422 | } else { |
||||||
423 | $gender = '<img src="assets/images/female.gif">'; |
||||||
424 | } |
||||||
425 | $link = '<a href="dog.php?id=' . $rowResult['id'] . '">' . \stripslashes($rowResult['pname']) . '</a>'; |
||||||
426 | $content .= $gender . ' ' . $link . '<br>'; |
||||||
427 | } |
||||||
428 | |||||||
429 | return $content; |
||||||
430 | } |
||||||
431 | |||||||
432 | /** |
||||||
433 | * @param $oid |
||||||
434 | * |
||||||
435 | * @return string |
||||||
436 | */ |
||||||
437 | public static function getName($oid) |
||||||
438 | { |
||||||
439 | $oid = (int)$oid; |
||||||
440 | $sqlQuery = 'SELECT pname FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE id = '{$oid}'"; |
||||||
441 | $queryResult = $GLOBALS['xoopsDB']->query($sqlQuery); |
||||||
442 | while (false !== ($rowResult = $GLOBALS['xoopsDB']->fetchArray($queryResult))) { |
||||||
443 | $an = \stripslashes($rowResult['pname']); |
||||||
444 | } |
||||||
445 | |||||||
446 | return $an; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
447 | } |
||||||
448 | |||||||
449 | /** |
||||||
450 | * @param $PA |
||||||
451 | */ |
||||||
452 | public static function showParent($PA) |
||||||
453 | { |
||||||
454 | $sqlQuery = 'SELECT pname FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " WHERE id='" . $PA . "'"; |
||||||
455 | $queryResult = $GLOBALS['xoopsDB']->query($sqlQuery); |
||||||
456 | while (false !== ($rowResult = $GLOBALS['xoopsDB']->fetchArray($queryResult))) { |
||||||
457 | $result = $rowResult['pname']; |
||||||
458 | } |
||||||
459 | if (isset($result)) { |
||||||
460 | return $result; |
||||||
461 | } |
||||||
462 | } |
||||||
463 | |||||||
464 | /** |
||||||
465 | * @param $pname_hond |
||||||
466 | * |
||||||
467 | * @return mixed |
||||||
468 | */ |
||||||
469 | public static function findId($pname_hond) |
||||||
470 | { |
||||||
471 | $sqlQuery = 'SELECT id FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " where pname= '$pname_hond'"; |
||||||
472 | $queryResult = $GLOBALS['xoopsDB']->query($sqlQuery); |
||||||
473 | while (false !== ($rowResult = $GLOBALS['xoopsDB']->fetchArray($queryResult))) { |
||||||
474 | $result = $rowResult['id']; |
||||||
475 | } |
||||||
476 | |||||||
477 | return $result; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
478 | } |
||||||
479 | |||||||
480 | /** |
||||||
481 | * @param $result |
||||||
482 | * @param $prefix |
||||||
483 | * @param $link |
||||||
484 | * @param $element |
||||||
485 | */ |
||||||
486 | public static function createList($result, $prefix, $link, $element) |
||||||
487 | { |
||||||
488 | global $xoopsTpl; |
||||||
489 | $animal = new Pedigree\Animal(); |
||||||
490 | //test to find out how many user fields there are... |
||||||
491 | $fields = $animal->getNumOfFields(); |
||||||
492 | $numofcolumns = 1; |
||||||
493 | $columns[] = ['columnname' => 'Name']; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
494 | for ($i = 0, $iMax = \count($fields); $i < $iMax; ++$i) { |
||||||
495 | $userField = new Field($fields[$i], $animal->getConfig()); |
||||||
496 | $fieldType = $userField->getSetting('FieldType'); |
||||||
497 | $fieldObject = new $fieldType($userField, $animal); |
||||||
498 | if ($userField->isActive() && $userField->inList()) { |
||||||
499 | if ($userField->hasLookup()) { |
||||||
500 | $id = $userField->getId(); |
||||||
501 | $q = $userField->lookupField($id); |
||||||
502 | } else { |
||||||
503 | $q = ''; |
||||||
504 | } |
||||||
505 | $columns[] = [ |
||||||
506 | 'columnname' => $fieldObject->fieldname, |
||||||
507 | 'columnnumber' => $userField->getId(), |
||||||
508 | 'lookuparray' => $q, |
||||||
509 | ]; |
||||||
510 | ++$numofcolumns; |
||||||
511 | } |
||||||
512 | } |
||||||
513 | |||||||
514 | //add preliminary row to array if passed |
||||||
515 | if (\is_array($prefix)) { |
||||||
516 | $dogs[] = $prefix; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
517 | } |
||||||
518 | |||||||
519 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
520 | //reset $gender |
||||||
521 | $gender = ''; |
||||||
522 | if ((!empty($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser'] instanceof \XoopsUser) |
||||||
523 | && ($row['user'] == $GLOBALS['xoopsUser']->getVar('uid') || true === $modadmin)) { |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
524 | $gender = "<a href='dog.php?id={$row['id']}'><img src='images/edit.png' alt='" . _EDIT . "'></a> |
||||||
525 | . <a href='delete.php?id={$row['id']}'><img src='images/delete.png' alt='" . _DELETE . "'></a>"; |
||||||
526 | } |
||||||
527 | |||||||
528 | $genImg = (0 == $row['roft']) ? 'male.gif' : 'female.gif'; |
||||||
529 | $gender .= "<img src='assets/images/{$genImg}'>"; |
||||||
530 | |||||||
531 | if ('' != $row['foto']) { |
||||||
532 | $camera = ' <img src="' . PEDIGREE_UPLOAD_URL . '/images/dog-icon25.png">'; |
||||||
0 ignored issues
–
show
|
|||||||
533 | } else { |
||||||
534 | $camera = ''; |
||||||
535 | } |
||||||
536 | $name = \stripslashes($row['pname']) . $camera; |
||||||
537 | unset($columnvalue); |
||||||
538 | |||||||
539 | //fill array |
||||||
540 | for ($i = 1; $i < $numofcolumns; ++$i) { |
||||||
541 | $x = $columns[$i]['columnnumber']; |
||||||
542 | $lookuparray = $columns[$i]['lookuparray']; |
||||||
543 | if (\is_array($lookuparray)) { |
||||||
544 | for ($index = 0, $indexMax = \count($lookuparray); $index < $indexMax; ++$index) { |
||||||
545 | if ($lookuparray[$index]['id'] == $row['user' . $x]) { |
||||||
546 | //echo "<h1>".$lookuparray[$index]['id']."</h1>"; |
||||||
547 | $value = $lookuparray[$index]['value']; |
||||||
548 | } |
||||||
549 | } |
||||||
550 | } //format value - cant use object because of query count |
||||||
551 | elseif (0 === \strncmp($row['user' . $x], 'http://', 7)) { |
||||||
552 | $value = '<a href="' . $row['user' . $x] . '">' . $row['user' . $x] . '</a>'; |
||||||
553 | } else { |
||||||
554 | $value = $row['user' . $x]; |
||||||
555 | } |
||||||
556 | $columnvalue[] = ['value' => $value]; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
557 | unset($value); |
||||||
558 | } |
||||||
559 | |||||||
560 | $linkto = '<a href="' . $link . $row[$element] . '">' . $name . '</a>'; |
||||||
561 | //create array |
||||||
562 | $dogs[] = [ |
||||||
563 | 'id' => $row['id'], |
||||||
564 | 'name' => $name, |
||||||
565 | 'gender' => $gender, |
||||||
566 | 'link' => $linkto, |
||||||
567 | 'colour' => '', |
||||||
568 | 'number' => '', |
||||||
569 | 'usercolumns' => $columnvalue, |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
570 | ]; |
||||||
571 | } |
||||||
572 | |||||||
573 | //add data to smarty template |
||||||
574 | //assign dog |
||||||
575 | $xoopsTpl->assign('dogs', $dogs); |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
576 | $xoopsTpl->assign('columns', $columns); |
||||||
577 | $xoopsTpl->assign('numofcolumns', $numofcolumns); |
||||||
578 | $xoopsTpl->assign('tsarray', self::sortTable($numofcolumns)); |
||||||
579 | } |
||||||
580 | |||||||
581 | /***************Blocks************** |
||||||
582 | * |
||||||
583 | * @param $cats |
||||||
584 | * |
||||||
585 | * @return string |
||||||
586 | */ |
||||||
587 | public static function animal_block_addCatSelect($cats) |
||||||
588 | { |
||||||
589 | if (\is_array($cats)) { |
||||||
590 | $cat_sql = '(' . \current($cats); |
||||||
591 | \array_shift($cats); |
||||||
592 | foreach ($cats as $cat) { |
||||||
593 | $cat_sql .= ',' . $cat; |
||||||
594 | } |
||||||
595 | $cat_sql .= ')'; |
||||||
596 | } |
||||||
597 | |||||||
598 | return $cat_sql; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
599 | } |
||||||
600 | |||||||
601 | /** |
||||||
602 | * @param $global |
||||||
603 | * @param $key |
||||||
604 | * @param string $default |
||||||
605 | * @param string $type |
||||||
606 | * |
||||||
607 | * @return mixed|string |
||||||
608 | * @deprecated |
||||||
609 | */ |
||||||
610 | public static function animal_CleanVars(&$global, $key, $default = '', $type = 'int') |
||||||
611 | { |
||||||
612 | switch ($type) { |
||||||
613 | case 'string': |
||||||
614 | $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_MAGIC_QUOTES) : $default; |
||||||
0 ignored issues
–
show
The constant
FILTER_SANITIZE_MAGIC_QUOTES has been deprecated: 7.4
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
615 | break; |
||||||
616 | case 'int': |
||||||
617 | default: |
||||||
618 | $ret = isset($global[$key]) ? \filter_var($global[$key], \FILTER_SANITIZE_NUMBER_INT) : $default; |
||||||
619 | break; |
||||||
620 | } |
||||||
621 | if (false === $ret) { |
||||||
622 | return $default; |
||||||
623 | } |
||||||
624 | |||||||
625 | return $ret; |
||||||
626 | } |
||||||
627 | |||||||
628 | /** |
||||||
629 | * @param $content |
||||||
630 | */ |
||||||
631 | public static function animal_meta_keywords($content) |
||||||
632 | { |
||||||
633 | global $xoopsTpl, $xoTheme; |
||||||
634 | $myts = \MyTextSanitizer::getInstance(); |
||||||
635 | $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
||||||
636 | if (isset($xoTheme) && \is_object($xoTheme)) { |
||||||
637 | $xoTheme->addMeta('meta', 'keywords', \strip_tags($content)); |
||||||
638 | } else { // Compatibility for old Xoops versions |
||||||
639 | $xoopsTpl->assign('xoops_meta_keywords', \strip_tags($content)); |
||||||
640 | } |
||||||
641 | } |
||||||
642 | |||||||
643 | /** |
||||||
644 | * @param $content |
||||||
645 | */ |
||||||
646 | public static function animal_meta_description($content) |
||||||
647 | { |
||||||
648 | global $xoopsTpl, $xoTheme; |
||||||
649 | $myts = \MyTextSanitizer::getInstance(); |
||||||
650 | $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
||||||
651 | if (isset($xoTheme) && \is_object($xoTheme)) { |
||||||
652 | $xoTheme->addMeta('meta', 'description', \strip_tags($content)); |
||||||
653 | } else { // Compatibility for old Xoops versions |
||||||
654 | $xoopsTpl->assign('xoops_meta_description', \strip_tags($content)); |
||||||
655 | } |
||||||
656 | } |
||||||
657 | |||||||
658 | /** |
||||||
659 | * Verify that a mysql table exists |
||||||
660 | * |
||||||
661 | * @param mixed $myObject |
||||||
662 | * @param mixed $activeObject |
||||||
663 | * @param mixed $criteria |
||||||
664 | * @param mixed $name |
||||||
665 | * @param mixed $link |
||||||
666 | * @param null|mixed $link2 |
||||||
667 | * @package pedigree |
||||||
668 | * @author Hervé Thouzard (http://www.herve-thouzard.com) |
||||||
669 | * @copyright (c) Hervé Thouzard |
||||||
670 | */ |
||||||
671 | //function tableExists($tablename) |
||||||
672 | //{ |
||||||
673 | // |
||||||
674 | // $result=$GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'"); |
||||||
675 | // return($GLOBALS['xoopsDB']->getRowsNum($result) > 0); |
||||||
676 | //} |
||||||
677 | |||||||
678 | /** |
||||||
679 | * Create download by letter choice bar/menu |
||||||
680 | * updated starting from this idea https://xoops.org/modules/news/article.php?storyid=6497 |
||||||
681 | * |
||||||
682 | * @param $myObject |
||||||
683 | * @param $activeObject |
||||||
684 | * @param $criteria |
||||||
685 | * @param $name |
||||||
686 | * @param $link |
||||||
687 | * @param null $link2 |
||||||
0 ignored issues
–
show
|
|||||||
688 | * @return string html |
||||||
689 | * |
||||||
690 | * @internal param $file |
||||||
691 | * @internal param $file2 |
||||||
692 | * @access public |
||||||
693 | * @author luciorota |
||||||
694 | */ |
||||||
695 | public static function lettersChoice($myObject, $activeObject, $criteria, $name, $link, $link2 = null) |
||||||
0 ignored issues
–
show
The parameter
$name is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
696 | { |
||||||
697 | /* |
||||||
698 | $pedigree = Helper::getInstance(); |
||||||
699 | xoops_load('XoopsLocal'); |
||||||
700 | |||||||
701 | $criteria = $pedigree->getHandler('tree')->getActiveCriteria(); |
||||||
702 | $criteria->setGroupby('UPPER(LEFT(pname,1))'); |
||||||
703 | $countsByLetters = $pedigree->getHandler('tree')->getCounts($criteria); |
||||||
704 | // Fill alphabet array |
||||||
705 | $alphabet = XoopsLocal::getAlphabet(); |
||||||
706 | $alphabet_array = array(); |
||||||
707 | foreach ($alphabet as $letter) { |
||||||
708 | $letter_array = array(); |
||||||
709 | if (isset($countsByLetters[$letter])) { |
||||||
710 | $letter_array['letter'] = $letter; |
||||||
711 | $letter_array['count'] = $countsByLetters[$letter]; |
||||||
712 | // $letter_array['url'] = "" . XOOPS_URL . "/modules/" . $pedigree->getModule()->dirname() . "/viewcat.php?list={$letter}"; |
||||||
713 | $letter_array['url'] = '' . XOOPS_URL . '/modules/' . $pedigree->getModule()->dirname() . "/result.php?f=pname&l=1&w={$letter}%25&o=pname"; |
||||||
714 | } else { |
||||||
715 | $letter_array['letter'] = $letter; |
||||||
716 | $letter_array['count'] = 0; |
||||||
717 | $letter_array['url'] = ''; |
||||||
718 | } |
||||||
719 | $alphabet_array[$letter] = $letter_array; |
||||||
720 | unset($letter_array); |
||||||
721 | } |
||||||
722 | // Render output |
||||||
723 | if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
||||||
724 | require_once $GLOBALS['xoops']->path('class/theme.php'); |
||||||
725 | $GLOBALS['xoTheme'] = new \xos_opal_Theme(); |
||||||
726 | } |
||||||
727 | require_once $GLOBALS['xoops']->path('class/template.php'); |
||||||
728 | $letterschoiceTpl = new \XoopsTpl(); |
||||||
729 | $letterschoiceTpl->caching = false; // Disable cache |
||||||
730 | $letterschoiceTpl->assign('alphabet', $alphabet_array); |
||||||
731 | $html = $letterschoiceTpl->fetch('db:' . $pedigree->getModule()->dirname() . '_common_letterschoice.tpl'); |
||||||
732 | unset($letterschoiceTpl); |
||||||
733 | return $html; |
||||||
734 | */ |
||||||
735 | |||||||
736 | // $pedigree = Helper::getInstance(); |
||||||
737 | \xoops_load('XoopsLocal'); |
||||||
738 | |||||||
739 | // $criteria = $myObject->getHandler($activeObject)->getActiveCriteria(); |
||||||
740 | // $criteria->setGroupby('UPPER(LEFT(' . $name . ',1))'); |
||||||
741 | $countsByLetters = $myObject->getHandler($activeObject)->getCounts($criteria); |
||||||
742 | // Fill alphabet array |
||||||
743 | // $xLocale = new \XoopsLocal; |
||||||
744 | // $alphabet = $xLocale->getAlphabet(); |
||||||
745 | $alphabet = \pedigreeGetAlphabet(); |
||||||
746 | $alphabet_array = []; |
||||||
747 | foreach ($alphabet as $letter) { |
||||||
748 | $letter_array = []; |
||||||
749 | if (isset($countsByLetters[$letter])) { |
||||||
750 | $letter_array['letter'] = $letter; |
||||||
751 | $letter_array['count'] = $countsByLetters[$letter]; |
||||||
752 | // $letter_array['url'] = "" . XOOPS_URL . "/modules/" . $pedigree->getModule()->dirname() . "/viewcat.php?list={$letter}"; |
||||||
753 | // $letter_array['url'] = '' . XOOPS_URL . '/modules/' . $myObject->getModule()->dirname() . '/'.$file.'?f='.$name."&l=1&w={$letter}%25&o=".$name; |
||||||
754 | $letter_array['url'] = '' . XOOPS_URL . '/modules/' . $myObject->getModule()->dirname() . '/' . $link . $letter . $link2; |
||||||
755 | } else { |
||||||
756 | $letter_array['letter'] = $letter; |
||||||
757 | $letter_array['count'] = 0; |
||||||
758 | $letter_array['url'] = ''; |
||||||
759 | } |
||||||
760 | $alphabet_array[$letter] = $letter_array; |
||||||
761 | unset($letter_array); |
||||||
762 | } |
||||||
763 | // Render output |
||||||
764 | if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) { |
||||||
765 | require_once $GLOBALS['xoops']->path('class/theme.php'); |
||||||
766 | $GLOBALS['xoTheme'] = new \xos_opal_Theme(); |
||||||
767 | } |
||||||
768 | require_once $GLOBALS['xoops']->path('class/template.php'); |
||||||
769 | $letterschoiceTpl = new \XoopsTpl(); |
||||||
770 | $letterschoiceTpl->caching = false; // Disable cache |
||||||
0 ignored issues
–
show
The property
$caching was declared of type integer , but false is of type false . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
![]() |
|||||||
771 | $letterschoiceTpl->assign('alphabet', $alphabet_array); |
||||||
772 | $html = $letterschoiceTpl->fetch('db:' . $myObject->getModule()->dirname() . '_common_letterschoice.tpl'); |
||||||
773 | unset($letterschoiceTpl); |
||||||
774 | |||||||
775 | return $html; |
||||||
776 | } |
||||||
777 | |||||||
778 | /** |
||||||
779 | * @return bool |
||||||
780 | */ |
||||||
781 | public static function userIsAdmin() |
||||||
782 | { |
||||||
783 | $pedigree = Helper::getInstance(); |
||||||
784 | |||||||
785 | static $pedigree_isAdmin; |
||||||
786 | |||||||
787 | if (isset($pedigree_isAdmin)) { |
||||||
788 | return $pedigree_isAdmin; |
||||||
789 | } |
||||||
790 | |||||||
791 | if (!$GLOBALS['xoopsUser']) { |
||||||
792 | $pedigree_isAdmin = false; |
||||||
793 | } else { |
||||||
794 | $pedigree_isAdmin = $GLOBALS['xoopsUser']->isAdmin($pedigree->getModule()->getVar('mid')); |
||||||
795 | } |
||||||
796 | |||||||
797 | return $pedigree_isAdmin; |
||||||
798 | } |
||||||
799 | |||||||
800 | public static function getXoopsCpHeader() |
||||||
801 | { |
||||||
802 | \xoops_cp_header(); |
||||||
803 | } |
||||||
804 | |||||||
805 | /** |
||||||
806 | * @param bool $withLink |
||||||
807 | * |
||||||
808 | * @return string |
||||||
809 | */ |
||||||
810 | public static function getModuleName($withLink = true) |
||||||
811 | { |
||||||
812 | $pedigree = Helper::getInstance(); |
||||||
813 | |||||||
814 | $pedigreeModuleName = $pedigree->getModule()->getVar('name'); |
||||||
815 | if (!$withLink) { |
||||||
816 | return $pedigreeModuleName; |
||||||
0 ignored issues
–
show
|
|||||||
817 | } |
||||||
818 | |||||||
819 | return '<a href="' . PEDIGREE_URL . '/">{$pedigreeModuleName}</a>'; |
||||||
0 ignored issues
–
show
|
|||||||
820 | } |
||||||
821 | |||||||
822 | /** |
||||||
823 | * Detemines if a table exists in the current db |
||||||
824 | * |
||||||
825 | * @param string $table the table name (without XOOPS prefix) |
||||||
826 | * |
||||||
827 | * @return bool True if table exists, false if not |
||||||
828 | * |
||||||
829 | * @access public |
||||||
830 | * @author xhelp development team |
||||||
831 | */ |
||||||
832 | public static function hasTable($table) |
||||||
833 | { |
||||||
834 | $bRetVal = false; |
||||||
835 | //Verifies that a MySQL table exists |
||||||
836 | $GLOBALS['xoopsDB'] = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
837 | $realName = $GLOBALS['xoopsDB']->prefix($table); |
||||||
838 | |||||||
839 | $sql = 'SHOW TABLES FROM ' . XOOPS_DB_NAME; |
||||||
840 | $ret = $GLOBALS['xoopsDB']->queryF($sql); |
||||||
841 | |||||||
842 | while (false !== (list($m_table) = $GLOBALS['xoopsDB']->fetchRow($ret))) { |
||||||
843 | if ($m_table == $realName) { |
||||||
844 | $bRetVal = true; |
||||||
845 | break; |
||||||
846 | } |
||||||
847 | } |
||||||
848 | $GLOBALS['xoopsDB']->freeRecordSet($ret); |
||||||
849 | |||||||
850 | return $bRetVal; |
||||||
851 | } |
||||||
852 | |||||||
853 | /** |
||||||
854 | * Gets a value from a key in the xhelp_meta table |
||||||
855 | * |
||||||
856 | * @param string $key |
||||||
857 | * |
||||||
858 | * @return string $value |
||||||
859 | * |
||||||
860 | * @access public |
||||||
861 | * @author xhelp development team |
||||||
862 | */ |
||||||
863 | public static function getMeta($key) |
||||||
864 | { |
||||||
865 | $GLOBALS['xoopsDB'] = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
866 | $sql = \sprintf('SELECT metavalue FROM `%s` WHERE metakey= `%s` ', $GLOBALS['xoopsDB']->prefix('pedigree_meta'), $GLOBALS['xoopsDB']->quoteString($key)); |
||||||
867 | $ret = $GLOBALS['xoopsDB']->query($sql); |
||||||
868 | if (!$ret) { |
||||||
869 | $value = false; |
||||||
870 | } else { |
||||||
871 | [$value] = $GLOBALS['xoopsDB']->fetchRow($ret); |
||||||
872 | } |
||||||
873 | |||||||
874 | return $value; |
||||||
875 | } |
||||||
876 | |||||||
877 | /** |
||||||
878 | * Sets a value for a key in the xhelp_meta table |
||||||
879 | * |
||||||
880 | * @param string $key |
||||||
881 | * @param string $value |
||||||
882 | * |
||||||
883 | * @return bool true if success, false if failure |
||||||
884 | * |
||||||
885 | * @access public |
||||||
886 | * @author xhelp development team |
||||||
887 | */ |
||||||
888 | public static function setMeta($key, $value) |
||||||
889 | { |
||||||
890 | $GLOBALS['xoopsDB'] = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
891 | if (false !== ($ret = self::getMeta($key))) { |
||||||
0 ignored issues
–
show
|
|||||||
892 | $sql = \sprintf('UPDATE `%s` SET metavalue = `%s` WHERE metakey = `%s` ', $GLOBALS['xoopsDB']->prefix('pedigree_meta'), $GLOBALS['xoopsDB']->quoteString($value), $GLOBALS['xoopsDB']->quoteString($key)); |
||||||
893 | } else { |
||||||
894 | $sql = \sprintf('INSERT INTO `%s` (metakey, metavalue) VALUES (`%s`, `%s` )', $GLOBALS['xoopsDB']->prefix('pedigree_meta'), $GLOBALS['xoopsDB']->quoteString($key), $GLOBALS['xoopsDB']->quoteString($value)); |
||||||
895 | } |
||||||
896 | $ret = $GLOBALS['xoopsDB']->queryF($sql); |
||||||
897 | if (!$ret) { |
||||||
898 | return false; |
||||||
899 | } |
||||||
900 | |||||||
901 | return true; |
||||||
902 | } |
||||||
903 | |||||||
904 | /** |
||||||
905 | * @param $name |
||||||
906 | * @param $value |
||||||
907 | * @param int $time |
||||||
908 | */ |
||||||
909 | public static function setCookieVar($name, $value, $time = 0) |
||||||
910 | { |
||||||
911 | if (0 == $time) { |
||||||
912 | $time = \time() + 3600 * 24 * 365; |
||||||
913 | //$time = ''; |
||||||
914 | } |
||||||
915 | setcookie($name, $value, $time, '/', \ini_get('session.cookie_domain'), \ini_get('session.cookie_secure'), \ini_get('session.cookie_httponly')); |
||||||
0 ignored issues
–
show
ini_get('session.cookie_secure') of type string is incompatible with the type boolean expected by parameter $secure of setcookie() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() ini_get('session.cookie_httponly') of type string is incompatible with the type boolean expected by parameter $httponly of setcookie() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
916 | } |
||||||
917 | |||||||
918 | /** |
||||||
919 | * @param $name |
||||||
920 | * @param string $default |
||||||
921 | * |
||||||
922 | * @return string |
||||||
923 | */ |
||||||
924 | public static function getCookieVar($name, $default = '') |
||||||
925 | { |
||||||
926 | if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
||||||
927 | return $_COOKIE[$name]; |
||||||
928 | } |
||||||
929 | |||||||
930 | return $default; |
||||||
931 | } |
||||||
932 | |||||||
933 | /** |
||||||
934 | * @return array |
||||||
935 | */ |
||||||
936 | public static function getCurrentUrls() |
||||||
937 | { |
||||||
938 | $http = (false === \mb_strpos(XOOPS_URL, 'https://')) ? 'http://' : 'https://'; |
||||||
939 | $phpSelf = $_SERVER['PHP_SELF']; |
||||||
940 | $httpHost = $_SERVER['HTTP_HOST']; |
||||||
941 | $sql = $_SERVER['QUERY_STRING']; |
||||||
942 | |||||||
943 | if ('' != $sql) { |
||||||
944 | $sql = '?' . $sql; |
||||||
945 | } |
||||||
946 | |||||||
947 | $currentURL = $http . $httpHost . $phpSelf . $sql; |
||||||
948 | |||||||
949 | $urls = []; |
||||||
950 | $urls['http'] = $http; |
||||||
951 | $urls['httphost'] = $httpHost; |
||||||
952 | $urls['phpself'] = $phpSelf; |
||||||
953 | $urls['querystring'] = $sql; |
||||||
954 | $urls['full'] = $currentURL; |
||||||
955 | |||||||
956 | return $urls; |
||||||
957 | } |
||||||
958 | |||||||
959 | /** |
||||||
960 | * @return mixed |
||||||
961 | */ |
||||||
962 | public static function getCurrentPage() |
||||||
963 | { |
||||||
964 | $urls = self::getCurrentUrls(); |
||||||
965 | |||||||
966 | return $urls['full']; |
||||||
967 | } |
||||||
968 | |||||||
969 | /** |
||||||
970 | * @param array $errors |
||||||
971 | * |
||||||
972 | * @return string |
||||||
973 | */ |
||||||
974 | public static function formatErrors($errors = []) |
||||||
975 | { |
||||||
976 | $ret = ''; |
||||||
977 | foreach ($errors as $key => $value) { |
||||||
978 | $ret .= "<br> - {$value}"; |
||||||
979 | } |
||||||
980 | |||||||
981 | return $ret; |
||||||
982 | } |
||||||
983 | } |
||||||
984 |