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 Xmf\Module\Admin; |
||
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 | //path taken |
||
34 | |||
35 | $GLOBALS['xoopsOption']['template_main'] = 'pedigree_latest.tpl'; |
||
36 | |||
37 | require $GLOBALS['xoops']->path('/header.php'); |
||
38 | |||
39 | //get module configuration |
||
40 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
41 | $moduleHandler = xoops_getHandler('module'); |
||
42 | $module = $moduleHandler->getByDirname($moduleDirName); |
||
43 | /** @var \XoopsConfigHandler $configHandler */ |
||
44 | $configHandler = xoops_getHandler('config'); |
||
45 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
46 | |||
47 | $st = Request::getInt('st', 0, 'GET'); |
||
48 | |||
49 | $perPage = $moduleConfig['perpage']; |
||
50 | global $xoopsTpl, $xoopsModuleConfig; |
||
51 | |||
52 | //iscurrent user a module admin ? |
||
53 | $modadmin = false; |
||
54 | $xoopsModule = XoopsModule::getByDirname($moduleDirName); |
||
55 | if (!empty($GLOBALS['xoopsUser'])) { |
||
56 | if ($GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { |
||
57 | $modadmin = true; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | //count total number of animals |
||
62 | $numanimal = 'SELECT id FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' NOLIMIT'; |
||
63 | $numRes = $GLOBALS['xoopsDB']->query($numanimal); |
||
64 | //total number of animals the query will find |
||
65 | $numResults = $GLOBALS['xoopsDB']->getRowsNum($numRes); |
||
66 | //total number of pages |
||
67 | $numPages = floor($numResults / $perPage) + 1; |
||
68 | if (($numPages * $perPage) == ($numResults + $perPage)) { |
||
69 | --$numPages; |
||
70 | } |
||
71 | //find current page |
||
72 | $currentPage = floor($st / $perPage) + 1; |
||
73 | |||
74 | //create numbers |
||
75 | for ($x = 1; $x < ($numPages + 1); ++$x) { |
||
76 | $pages = $x . '  '; |
||
77 | } |
||
78 | |||
79 | //query |
||
80 | $sql = 'SELECT d.id AS d_id, d.pname AS d_pname, d.roft AS d_roft, d.mother AS d_mother, d.father AS d_father, d.foto AS d_foto, d.user AS d_user, f.id AS f_id, f.pname AS f_pname, m.id AS m_id, m.pname AS m_pname, u.uname AS u_uname FROM ' |
||
81 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
82 | . ' d LEFT JOIN ' |
||
83 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
84 | . ' f ON d.father = f.id LEFT JOIN ' |
||
85 | . $GLOBALS['xoopsDB']->prefix('pedigree_registry') |
||
86 | . ' m ON d.mother = m.id LEFT JOIN ' |
||
87 | . $GLOBALS['xoopsDB']->prefix('users') |
||
88 | . ' u ON d.user = u.uid ORDER BY d.id DESC LIMIT ' |
||
89 | . $st |
||
90 | . ', ' |
||
91 | . $perPage; |
||
92 | $result = $GLOBALS['xoopsDB']->query($sql); |
||
93 | $pathIcon16 = Admin::iconUrl('', 16); |
||
94 | |||
95 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
96 | //reset $gender |
||
97 | $gender = ''; |
||
98 | if (!empty($GLOBALS['xoopsUser'])) { |
||
99 | if ($row['d_user'] == $GLOBALS['xoopsUser']->getVar('uid') || true === $modadmin) { |
||
100 | $gender = '<a href="dog.php?id=' . $row['d_id'] . '"><img src=' . $pathIcon16 . '/edit.png alt=' . _EDIT . '></a><a href="delete.php?id=' . $row['d_id'] . '"><img src=' . $pathIcon16 . '/delete.png alt=' . _DELETE . '></a>'; |
||
101 | } else { |
||
102 | $gender = ''; |
||
103 | } |
||
104 | } |
||
105 | |||
106 | if ('' != $row['d_foto']) { |
||
107 | $camera = ' <img src="assets/images/camera.png">'; |
||
108 | } else { |
||
109 | $camera = ''; |
||
110 | } |
||
111 | |||
112 | if (0 == $row['d_roft']) { |
||
113 | $gender .= '<img src="assets/images/male.gif">'; |
||
114 | } else { |
||
115 | $gender .= '<img src="assets/images/female.gif">'; |
||
116 | } |
||
117 | //create string for parents |
||
118 | if ('' == $row['f_pname']) { |
||
119 | $dad = _MA_PEDIGREE_UNKNOWN; |
||
120 | } else { |
||
121 | $dad = '<a href="pedigree.php?pedid=' . $row['f_id'] . '">' . stripslashes($row['f_pname']) . '</a>'; |
||
122 | } |
||
123 | if ('' == $row['m_pname']) { |
||
124 | $mom = _MA_PEDIGREE_UNKNOWN; |
||
125 | } else { |
||
126 | $mom = '<a href="pedigree.php?pedid=' . $row['m_id'] . '">' . stripslashes($row['m_pname']) . '</a>'; |
||
127 | } |
||
128 | $parents = $dad . ' x ' . $mom; |
||
129 | //create array for animals |
||
130 | $animals[] = [ |
||
131 | 'id' => $row['d_id'], |
||
132 | 'name' => stripslashes($row['d_pname']) . $camera, |
||
133 | 'gender' => $gender, |
||
134 | 'parents' => $parents, |
||
135 | 'addedby' => '<a href="../../userinfo.php?uid=' . $row['d_user'] . '">' . $row['u_uname'] . '</a>', |
||
136 | ]; |
||
137 | //reset rights ready for the next dog |
||
138 | $editdel = '0'; |
||
139 | } |
||
140 | |||
141 | //add data to smarty template |
||
142 | //assign dog |
||
143 | if (isset($animals)) { |
||
144 | $xoopsTpl->assign('dogs', $animals); |
||
145 | } |
||
146 | |||
147 | //find last shown number |
||
148 | if (($st + $perPage) > $numResults) { |
||
149 | $lastshown = $numResults; |
||
150 | } else { |
||
151 | $lastshown = $st + $perPage; |
||
152 | } |
||
153 | //create string |
||
154 | $matches = strtr(_MA_PEDIGREE_MATCHES, ['[animalTypes]' => $helper->getConfig('animalTypes')]); |
||
155 | $nummatchstr = $numResults . $matches . ($st + 1) . '-' . $lastshown . ' (' . $numPages . ' pages)'; |
||
156 | $xoopsTpl->assign('nummatch', $nummatchstr); |
||
157 | if (isset($pages)) { |
||
158 | $xoopsTpl->assign('pages', $pages); |
||
159 | } |
||
160 | $xoopsTpl->assign('name', _MA_PEDIGREE_FLD_NAME); |
||
161 | $xoopsTpl->assign('parents', _MA_PEDIGREE_PA); |
||
162 | $xoopsTpl->assign('addedby', _MA_PEDIGREE_FLD_DBUS); |
||
163 | //comments and footer |
||
164 | require XOOPS_ROOT_PATH . '/footer.php'; |
||
165 |
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: