mambax7 /
pedigree
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 |
||||
| 4 | of supporting developers from this source code or any supporting source code |
||||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 6 | |||||
| 7 | This program is distributed in the hope that it will be useful, |
||||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 10 | */ |
||||
| 11 | |||||
| 12 | /** |
||||
| 13 | * Module: Pedigree animal module for XOOPS |
||||
| 14 | * |
||||
| 15 | * @package XoopsModules\Pedigree |
||||
| 16 | * @copyright {@link http://sourceforge.net/projects/thmod/ The TXMod XOOPS Project} |
||||
| 17 | * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} |
||||
| 18 | * @license GPL 2.0 or later |
||||
| 19 | * @author XOOPS Mod Development Team |
||||
| 20 | * |
||||
| 21 | * @todo move hard coded language strings to language file |
||||
| 22 | */ |
||||
| 23 | |||||
| 24 | use Xmf\Request; |
||||
|
0 ignored issues
–
show
|
|||||
| 25 | use XoopsModules\Pedigree; |
||||
| 26 | use XoopsModules\Pedigree\Constants; |
||||
| 27 | |||||
| 28 | require_once __DIR__ . '/header.php'; |
||||
| 29 | /** @var XoopsModules\Pedigree\Helper $helper */ |
||||
| 30 | $helper->loadLanguage('main'); |
||||
| 31 | |||||
| 32 | //check for access - only allow registered users |
||||
| 33 | //$xoopsModule = XoopsModule::getByDirname($moduleDirName); |
||||
| 34 | if (empty($GLOBALS['xoopsUser']) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
||||
| 35 | redirect_header('javascript:history.go(-1)', 3, _NOPERM . '<br>' . _MA_PEDIGREE_REGIST); |
||||
| 36 | } |
||||
| 37 | |||||
| 38 | // Include any common code for this module. |
||||
| 39 | require_once $helper->path('include/common.php'); |
||||
| 40 | |||||
| 41 | /* |
||||
| 42 | $GLOBALS['xoopsOption']['template_main'] = "pedigree_update.tpl"; |
||||
| 43 | |||||
| 44 | include $GLOBALS['xoops']->path('/header.php'); |
||||
| 45 | $GLOBALS['xoopsTpl']->assign('page_title', "Pedigree database - Update details"); |
||||
| 46 | */ |
||||
| 47 | |||||
| 48 | //check XOOPS security token |
||||
| 49 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
| 50 | $helper->redirect('', Constants::REDIRECT_DELAY_MEDIUM, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
| 51 | } |
||||
| 52 | |||||
| 53 | //possible variables (specific variables are found in the specified IF statement |
||||
| 54 | $dogid = Request::getInt('dogid', 0, 'POST'); |
||||
| 55 | $ownerId = Request::getInt('ownerid', 0, 'POST'); |
||||
| 56 | |||||
| 57 | /* |
||||
| 58 | $table = $_POST['dbtable']; |
||||
| 59 | $field = $_POST['dbfield']; |
||||
| 60 | $dogname = $_POST['curname']; |
||||
| 61 | $name = $_POST['pname']; |
||||
| 62 | $gender = $_POST['roft']; |
||||
| 63 | */ |
||||
| 64 | $table = Request::getString('dbtable', '', 'POST'); |
||||
| 65 | $field = Request::getString('dbfield', '', 'POST'); |
||||
| 66 | $field = $GLOBALS['xoopsDB']->escape('`' . $field . '`'); |
||||
| 67 | $dogname = Request::getString('curname', '', 'POST'); |
||||
| 68 | $name = Request::getString('pname', '', 'POST'); |
||||
| 69 | //$gender = Request::getInt('roft', 0, 'POST'); |
||||
| 70 | $gender = Request::getString('roft', '', 'POST'); //Richard |
||||
| 71 | $id_owner = Request::getInt('id_owner', 0, 'POST'); |
||||
| 72 | |||||
| 73 | //$id = (!isset($_POST['dogid']) ? $id = '' : $id = $_POST['dogid']); |
||||
| 74 | $animal = new Pedigree\Animal($dogid); |
||||
| 75 | $fields = $animal->getNumOfFields(); |
||||
| 76 | |||||
| 77 | foreach ($fields as $i => $iValue) { |
||||
| 78 | if ('user' . $iValue === $_POST['dbfield']) { |
||||
| 79 | $userField = new Pedigree\Field($fields[$i], $animal->getConfig()); |
||||
| 80 | if ($userField->isActive()) { |
||||
| 81 | $currentfield = 'user' . $iValue; |
||||
| 82 | $pictureField = $_FILES[$currentfield]['name']; |
||||
| 83 | if (empty($pictureField)) { |
||||
| 84 | $newvalue = $_POST['user' . $iValue]; |
||||
| 85 | } else { |
||||
| 86 | $newvalue = Pedigree\Utility::uploadPicture(0); |
||||
| 87 | } |
||||
| 88 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . " SET {$field}='{$newvalue}' WHERE id='{$dogid}'"; |
||||
| 89 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 90 | |||||
| 91 | $ch = 1; |
||||
| 92 | } |
||||
| 93 | } |
||||
| 94 | } |
||||
| 95 | |||||
| 96 | $ch = false; |
||||
| 97 | $chow = false; |
||||
| 98 | |||||
| 99 | //name |
||||
| 100 | if (!empty($name)) { |
||||
| 101 | $curval = Request::getString('curvalname', '', 'POST'); |
||||
| 102 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . " SET {$field}='{$name}' WHERE id='{$dogid}'"; |
||||
| 103 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $GLOBALS['xoopsDB']->escape($name) . "' WHERE id='" . $dogid . "'"; |
||||
| 104 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 105 | |||||
| 106 | $ch = true; |
||||
| 107 | } |
||||
| 108 | //owner |
||||
| 109 | if (isset($_POST['id_owner'])) { |
||||
| 110 | $curval = Request::getInt('curvaleig', 0, 'POST'); |
||||
| 111 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . " SET {$field}='" . $_POST['id_owner'] . "' WHERE id='{$dogid}'"; |
||||
| 112 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['id_owner'] . "' WHERE id='" . $dogid . "'"; |
||||
| 113 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 114 | |||||
| 115 | $ch = true; |
||||
| 116 | } |
||||
| 117 | //breeder |
||||
| 118 | if (isset($_POST['id_breeder'])) { |
||||
| 119 | $curval = Request::getInt('curvalfok', 0, 'POST'); |
||||
| 120 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . " SET {$field}='" . $_POST['id_breeder'] . "' WHERE id='{$dogid}'"; |
||||
| 121 | $id_breeder = Request::getInt('id_breeder', 0, 'post'); |
||||
| 122 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $id_breeder . "' WHERE id='" . $dogid . "'"; |
||||
| 123 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 124 | |||||
| 125 | $ch = true; |
||||
| 126 | } |
||||
| 127 | //gender |
||||
| 128 | if (!empty($_POST['roft']) || '0' == $_POST['roft']) { |
||||
| 129 | $curval = $_POST['curvalroft']; |
||||
| 130 | $curval = Request::getInt('curvalroft', 0, 'POST'); |
||||
| 131 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . " SET {$field}='" . $_POST['roft'] . "' WHERE id='{$dogid}'"; |
||||
| 132 | $roft = Request::getInt('roft', 0, 'post'); |
||||
| 133 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $roft . "' WHERE id='" . $dogid . "'"; |
||||
| 134 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 135 | |||||
| 136 | $ch = true; |
||||
| 137 | } |
||||
| 138 | //sire - dam |
||||
| 139 | if (isset($_GET['gend'])) { |
||||
| 140 | $curval = Request::getInt('curval', 0, 'GET'); |
||||
| 141 | $thisid = Request::getInt('thisid', 0, 'GET'); |
||||
| 142 | //$curname = Pedigree\Utility::getName($curval); |
||||
| 143 | $table = 'pedigree_tree'; |
||||
| 144 | if (0 == Request::getInt('gend', '', 'GET')) { |
||||
|
0 ignored issues
–
show
'' of type string is incompatible with the type integer expected by parameter $default of Xmf\Request::getInt().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 145 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . " SET father='" . $thisid . "' WHERE id='{$curval}'"; |
||||
| 146 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 147 | } else { |
||||
| 148 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . " SET mother='" . $thisid . "' WHERE id='{$curval}'"; |
||||
| 149 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 150 | } |
||||
| 151 | |||||
| 152 | $ch = true; |
||||
| 153 | $dogid = $curval; |
||||
| 154 | } |
||||
| 155 | //picture |
||||
| 156 | if ('foto' === $_POST['dbfield']) { |
||||
| 157 | $curval = Request::getString('curvalpic', '', 'POST'); |
||||
| 158 | $foto = Pedigree\Utility::uploadPicture(0); |
||||
| 159 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . " SET foto='" . $GLOBALS['xoopsDB']->escape($foto) . "' WHERE id='{$dogid}'"; |
||||
| 160 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 161 | |||||
| 162 | $ch = true; |
||||
| 163 | } |
||||
| 164 | |||||
| 165 | //owner |
||||
| 166 | //lastname |
||||
| 167 | if (isset($_POST['pnamel'])) { |
||||
| 168 | // $curval = $_POST['curvalnamel']; |
||||
| 169 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['pnamel'] . "' WHERE id='" . $dogid . "'"; |
||||
| 170 | $curval = Request::getString('curvalnamel', '', 'POST'); |
||||
| 171 | $pnamel = Request::getString('pnamel', '', 'POST'); |
||||
| 172 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $GLOBALS['xoopsDB']->escape($pnamel) . "' WHERE id='" . $dogid . "'"; |
||||
| 173 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 174 | $chow = true; |
||||
| 175 | } |
||||
| 176 | //firstname |
||||
| 177 | if (isset($_POST['pnamef'])) { |
||||
| 178 | // $curval = $_POST['curvalnamef']; |
||||
| 179 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['pnamef'] . "' WHERE id='" . $dogid . "'"; |
||||
| 180 | $curval = Request::getString('curvalnamef', '', 'POST'); |
||||
| 181 | $pnamel = Request::getString('pnamef', '', 'POST'); |
||||
| 182 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $GLOBALS['xoopsDB']->escape($pnamef) . "' WHERE id='" . $dogid . "'"; |
||||
| 183 | $GLOBALS['xoopsDB']->query($sql); |
||||
| 184 | $chow = true; |
||||
| 185 | } |
||||
| 186 | //streetname |
||||
| 187 | if (isset($_POST['street'])) { |
||||
| 188 | // $curval = $_POST['curvalstreet']; |
||||
| 189 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['street'] . "' WHERE id='" . $dogid . "'"; |
||||
| 190 | $curval = Request::getString('curvalstreet', '', 'POST'); |
||||
| 191 | $street = $GLOBALS['xoopsDB']->escape(Request::getString('street', '', 'POST')); |
||||
| 192 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $street . "' WHERE id='" . $dogid . "'"; |
||||
| 193 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 194 | $chow = true; |
||||
| 195 | } |
||||
| 196 | //housenumber |
||||
| 197 | if (isset($_POST['housenumber'])) { |
||||
| 198 | // $curval = $_POST['curvalhousenumber']; |
||||
| 199 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['housenumber'] . "' WHERE id='" . $dogid . "'"; |
||||
| 200 | $curval = Request::getString('curvalhousenumber', '', 'POST'); |
||||
| 201 | $housenumber = $GLOBALS['xoopsDB']->escape(Request::getString('housenumber', '', 'POST')); |
||||
| 202 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $housenumber . "' WHERE id='" . $dogid . "'"; |
||||
| 203 | $GLOBALS['xoopsDB']->queryF($sql); |
||||
| 204 | $chow = true; |
||||
| 205 | } |
||||
| 206 | //postcode |
||||
| 207 | if (isset($_POST['postcode'])) { |
||||
| 208 | // $curval = $_POST['curvalpostcode']; |
||||
| 209 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['postcode'] . "' WHERE id='" . $dogid . "'"; |
||||
| 210 | $curval = Request::getString('curvalpostcode', '', 'POST'); |
||||
| 211 | $postcode = $GLOBALS['xoopsDB']->escape(Request::getString('postcode', '', 'POST')); |
||||
| 212 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $postcode . "' WHERE id='" . $dogid . "'"; |
||||
| 213 | $GLOBALS['xoopsDB']->query($sql); |
||||
| 214 | $chow = true; |
||||
| 215 | } |
||||
| 216 | //city |
||||
| 217 | if (isset($_POST['city'])) { |
||||
| 218 | // $curval = $_POST['curvalcity']; |
||||
| 219 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['city'] . "' WHERE id='" . $dogid . "'"; |
||||
| 220 | $curval = Request::getString('curvalcity', '', 'POST'); |
||||
| 221 | $city = $GLOBALS['xoopsDB']->escape(Request::getString('city', '', 'POST')); |
||||
| 222 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $city . "' WHERE id='" . $dogid . "'"; |
||||
| 223 | $GLOBALS['xoopsDB']->query($sql); |
||||
| 224 | $chow = true; |
||||
| 225 | } |
||||
| 226 | //phonenumber |
||||
| 227 | if (isset($_POST['phonenumber'])) { |
||||
| 228 | // $curval = $_POST['curvalphonenumber']; |
||||
| 229 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['phonenumber'] . "' WHERE id='" . $dogid . "'"; |
||||
| 230 | $curval = Request::getString('curvalphonenumber', '', 'POST'); |
||||
| 231 | $phonenumber = $GLOBALS['xoopsDB']->escape(Request::getString('phonenumber', '', 'POST')); |
||||
| 232 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $phonenumber . "' WHERE id='" . $dogid . "'"; |
||||
| 233 | $GLOBALS['xoopsDB']->query($sql); |
||||
| 234 | $chow = true; |
||||
| 235 | } |
||||
| 236 | |||||
| 237 | if (isset($_POST['email'])) { |
||||
| 238 | // $curval = $_POST['curvalemail']; |
||||
| 239 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['email'] . "' WHERE id='" . $dogid . "'"; |
||||
| 240 | $curval = Request::getString('curvalemail', '', 'POST'); |
||||
| 241 | $email = $GLOBALS['xoopsDB']->escape(Request::getEmail('email', '', 'POST')); |
||||
| 242 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $email . "' WHERE id='" . $dogid . "'"; |
||||
| 243 | $GLOBALS['xoopsDB']->query($sql); |
||||
| 244 | $chow = true; |
||||
| 245 | } |
||||
| 246 | //website |
||||
| 247 | if (isset($_POST['web'])) { |
||||
| 248 | // $curval = $_POST['curvalweb']; |
||||
| 249 | // $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $_POST['web'] . "' WHERE id='" . $dogid . "'"; |
||||
| 250 | $curval = Request::getString('curvalweb', '', 'POST'); |
||||
| 251 | $web = $GLOBALS['xoopsDB']->escape(Request::getUrl('web', '', 'POST')); |
||||
| 252 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($table) . ' SET ' . $field . "='" . $web . "' WHERE id='" . $dogid . "'"; |
||||
| 253 | $GLOBALS['xoopsDB']->query($sql); |
||||
| 254 | $chow = true; |
||||
| 255 | } |
||||
| 256 | |||||
| 257 | //check for access and completion |
||||
| 258 | if ($ch) { |
||||
| 259 | $helper->redirect('dog.php?id=' . $dogid, Constants::REDIRECT_DELAY_SHORT, _MD_DATACHANGED); |
||||
| 260 | } elseif ($chow) { |
||||
| 261 | $helper->redirect('owner.php?ownid=' . $dogid, Constants::REDIRECT_DELAY_SHORT, _MD_DATACHANGED); |
||||
| 262 | } else { |
||||
| 263 | //@todo REFACTOR THIS CODE - IT IS A POTENTIAL SECURITY RISK |
||||
| 264 | foreach ($_POST as $key => $values) { |
||||
| 265 | $filesval .= $key . ' : ' . Request::getString($values) . '<br>'; |
||||
| 266 | } |
||||
| 267 | |||||
| 268 | $helper->redirect('dog.php?id=' . $dogid, Constants::REDIRECT_DELAY_LONG, 'ERROR!!<br>' . $filesval); |
||||
| 269 | } |
||||
| 270 | //footer |
||||
| 271 | require XOOPS_ROOT_PATH . '/footer.php'; |
||||
| 272 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: