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 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; |
||||
| 23 | |||||
| 24 | require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
||||
| 25 | if (!isset($_GET['target']) && !isset($_POST['target'])) { |
||||
| 26 | exit(); |
||||
| 27 | } |
||||
| 28 | $op = 'list'; |
||||
| 29 | if (isset($_GET['op']) && 'upload' === Request::getCmd('op', '', 'GET')) { |
||||
| 30 | $op = 'upload'; |
||||
| 31 | } |
||||
| 32 | if (isset($_POST)) { |
||||
| 33 | foreach ($_POST as $k => $v) { |
||||
| 34 | ${$k} = $v; |
||||
| 35 | } |
||||
| 36 | } |
||||
| 37 | if (!$xoopsUser) { |
||||
| 38 | $group = [XOOPS_GROUP_ANONYMOUS]; |
||||
| 39 | } else { |
||||
| 40 | $group = $xoopsUser->getGroups(); |
||||
| 41 | } |
||||
| 42 | if ('list' === $op) { |
||||
| 43 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||||
| 44 | $xoopsTpl = new \XoopsTpl(); |
||||
| 45 | $xoopsTpl->assign('lang_imgmanager', _IMGMANAGER); |
||||
| 46 | $xoopsTpl->assign('sitename', $xoopsConfig['sitename']); |
||||
| 47 | $target = htmlspecialchars($_GET['target'], ENT_QUOTES); |
||||
| 48 | $xoopsTpl->assign('target', $target); |
||||
| 49 | $imgcatHandler = xoops_getHandler('imagecategory'); |
||||
| 50 | $catlist = $imgcatHandler->getList($group, 'imgcat_read', 1); |
||||
| 51 | $catcount = count($catlist); |
||||
| 52 | $xoopsTpl->assign('lang_align', _ALIGN); |
||||
| 53 | $xoopsTpl->assign('lang_add', _ADD); |
||||
| 54 | $xoopsTpl->assign('lang_close', _CLOSE); |
||||
| 55 | if ($catcount > 0) { |
||||
| 56 | $xoopsTpl->assign('lang_go', _GO); |
||||
| 57 | $catshow = Request::getInt('cat_id', 0, 'GET'); |
||||
| 58 | $catshow = (!empty($catshow) && array_key_exists($catshow, $catlist)) ? $catshow : 0; |
||||
| 59 | $xoopsTpl->assign('show_cat', $catshow); |
||||
| 60 | if ($catshow > 0) { |
||||
| 61 | $xoopsTpl->assign('lang_addimage', _ADDIMAGE); |
||||
| 62 | } |
||||
| 63 | $catlist = ['0' => '--'] + $catlist; |
||||
| 64 | $cat_options = ''; |
||||
| 65 | foreach ($catlist as $c_id => $c_name) { |
||||
| 66 | $sel = ''; |
||||
| 67 | if ($c_id == $catshow) { |
||||
| 68 | $sel = ' selected'; |
||||
| 69 | } |
||||
| 70 | $cat_options .= '<option value="' . $c_id . '"' . $sel . '>' . $c_name . '</option>'; |
||||
| 71 | } |
||||
| 72 | $xoopsTpl->assign('cat_options', $cat_options); |
||||
| 73 | if ($catshow > 0) { |
||||
| 74 | $imageHandler = xoops_getHandler('image'); |
||||
| 75 | $criteria = new \CriteriaCompo(new \Criteria('imgcat_id', $catshow)); |
||||
| 76 | $criteria->add(new \Criteria('image_display', 1)); |
||||
| 77 | $total = $imageHandler->getCount($criteria); |
||||
| 78 | if ($total > 0) { |
||||
| 79 | $imgcatHandler = xoops_getHandler('imagecategory'); |
||||
| 80 | $imgcat = $imgcatHandler->get($catshow); |
||||
| 81 | $xoopsTpl->assign('image_total', $total); |
||||
| 82 | $xoopsTpl->assign('lang_image', _IMAGE); |
||||
| 83 | $xoopsTpl->assign('lang_imagename', _IMAGENAME); |
||||
| 84 | $xoopsTpl->assign('lang_imagemime', _IMAGEMIME); |
||||
| 85 | $start = Request::getInt('start', 0, 'GET'); |
||||
| 86 | $criteria->setLimit(10); |
||||
| 87 | $criteria->setStart($start); |
||||
| 88 | $storetype = $imgcat->getVar('imgcat_storetype'); |
||||
| 89 | if ('db' === $storetype) { |
||||
| 90 | $images = $imageHandler->getObjects($criteria, false, true); |
||||
| 91 | } else { |
||||
| 92 | $images = $imageHandler->getObjects($criteria, false, false); |
||||
| 93 | } |
||||
| 94 | $imgcount = count($images); |
||||
| 95 | $max = ($imgcount > 10) ? 10 : $imgcount; |
||||
| 96 | |||||
| 97 | for ($i = 0; $i < $max; ++$i) { |
||||
| 98 | if ('db' === $storetype) { |
||||
| 99 | $lcode = '[img align=left id=' . $images[$i]->getVar('image_id') . ']' . $images[$i]->getVar('image_nicename') . '[/img]'; |
||||
| 100 | $code = '[img id=' . $images[$i]->getVar('image_id') . ']' . $images[$i]->getVar('image_nicename') . '[/img]'; |
||||
| 101 | $rcode = '[img align=right id=' . $images[$i]->getVar('image_id') . ']' . $images[$i]->getVar('image_nicename') . '[/img]'; |
||||
| 102 | $src = XOOPS_URL . '/image.php?id=' . $images[$i]->getVar('image_id'); |
||||
| 103 | } else { |
||||
| 104 | $lcode = '[img align=left]' . XOOPS_UPLOAD_URL . '/' . $images[$i]->getVar('image_name') . '[/img]'; |
||||
| 105 | $code = '[img]' . XOOPS_UPLOAD_URL . '/' . $images[$i]->getVar('image_name') . '[/img]'; |
||||
| 106 | $rcode = '[img align=right]' . XOOPS_UPLOAD_URL . '/' . $images[$i]->getVar('image_name') . '[/img]'; |
||||
| 107 | $src = XOOPS_UPLOAD_URL . '/' . $images[$i]->getVar('image_name'); |
||||
| 108 | } |
||||
| 109 | $xoopsTpl->append('images', [ |
||||
| 110 | 'id' => $images[$i]->getVar('image_id'), |
||||
| 111 | 'nicename' => $images[$i]->getVar('image_nicename'), |
||||
| 112 | 'mimetype' => $images[$i]->getVar('image_mimetype'), |
||||
| 113 | 'src' => $src, |
||||
| 114 | 'lxcode' => $lcode, |
||||
| 115 | 'xcode' => $code, |
||||
| 116 | 'rxcode' => $rcode, |
||||
| 117 | ]); |
||||
| 118 | } |
||||
| 119 | if ($total > 10) { |
||||
| 120 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||||
| 121 | $nav = new \XoopsPageNav($total, 10, $start, 'start', 'target=' . $target . '&cat_id=' . $catshow); |
||||
| 122 | $xoopsTpl->assign('pagenav', $nav->renderNav()); |
||||
| 123 | } |
||||
| 124 | } else { |
||||
| 125 | $xoopsTpl->assign('image_total', 0); |
||||
| 126 | } |
||||
| 127 | } |
||||
| 128 | $xoopsTpl->assign('xsize', 600); |
||||
| 129 | $xoopsTpl->assign('ysize', 400); |
||||
| 130 | } else { |
||||
| 131 | $xoopsTpl->assign('xsize', 400); |
||||
| 132 | $xoopsTpl->assign('ysize', 180); |
||||
| 133 | } |
||||
| 134 | $xoopsTpl->display('db:system_imagemanager.tpl'); |
||||
| 135 | exit(); |
||||
| 136 | } |
||||
| 137 | |||||
| 138 | if ('upload' === $op) { |
||||
| 139 | $imgcatHandler = xoops_getHandler('imagecategory'); |
||||
| 140 | $imgcat_id = Request::getInt('imgcat_id', 0, 'GET'); |
||||
| 141 | $imgcat = $imgcatHandler->get($imgcat_id); |
||||
| 142 | $error = false; |
||||
| 143 | if (!is_object($imgcat)) { |
||||
| 144 | $error = true; |
||||
| 145 | } else { |
||||
| 146 | $imgcatpermHandler = xoops_getHandler('groupperm'); |
||||
| 147 | if ($xoopsUser) { |
||||
| 148 | if (!$imgcatpermHandler->checkRight('imgcat_write', $imgcat_id, $xoopsUser->getGroups())) { |
||||
| 149 | $error = true; |
||||
| 150 | } |
||||
| 151 | } else { |
||||
| 152 | if (!$imgcatpermHandler->checkRight('imgcat_write', $imgcat_id, XOOPS_GROUP_ANONYMOUS)) { |
||||
| 153 | $error = true; |
||||
| 154 | } |
||||
| 155 | } |
||||
| 156 | } |
||||
| 157 | if (false !== $error) { |
||||
| 158 | xoops_header(false); |
||||
| 159 | echo '</head><body><div style="text-align:center;"><input value="' . _BACK . '" type="button" onclick="javascript:history.go(-1);"></div>'; |
||||
| 160 | xoops_footer(); |
||||
| 161 | exit(); |
||||
| 162 | } |
||||
| 163 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||||
| 164 | $xoopsTpl = new \XoopsTpl(); |
||||
| 165 | $xoopsTpl->assign('show_cat', $imgcat_id); |
||||
| 166 | $xoopsTpl->assign('lang_imgmanager', _IMGMANAGER); |
||||
| 167 | $xoopsTpl->assign('sitename', $xoopsConfig['sitename']); |
||||
| 168 | $xoopsTpl->assign('target', htmlspecialchars($_GET['target'], ENT_QUOTES)); |
||||
| 169 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||
| 170 | $form = new \XoopsThemeForm('', 'image_form', 'imagemanager.php'); |
||||
| 171 | $form->setExtra('enctype="multipart/form-data"'); |
||||
| 172 | $form->addElement(new \XoopsFormText(_IMAGENAME, 'image_nicename', 20, 255), true); |
||||
| 173 | $form->addElement(new \XoopsFormLabel(_IMAGECAT, $imgcat->getVar('imgcat_name'))); |
||||
| 174 | $form->addElement(new \XoopsFormFile(_IMAGEFILE, 'image_file', $imgcat->getVar('imgcat_maxsize')), true); |
||||
| 175 | $form->addElement(new \XoopsFormLabel(_IMGMAXSIZE, $imgcat->getVar('imgcat_maxsize'))); |
||||
| 176 | $form->addElement(new \XoopsFormLabel(_IMGMAXWIDTH, $imgcat->getVar('imgcat_maxwidth'))); |
||||
| 177 | $form->addElement(new \XoopsFormLabel(_IMGMAXHEIGHT, $imgcat->getVar('imgcat_maxheight'))); |
||||
| 178 | $form->addElement(new \XoopsFormHidden('imgcat_id', $imgcat_id)); |
||||
| 179 | $form->addElement(new \XoopsFormHidden('op', 'doupload')); |
||||
| 180 | $form->addElement(new \XoopsFormHidden('target', $target)); |
||||
| 181 | $form->addElement(new \XoopsFormButton('', 'img_button', _SUBMIT, 'submit')); |
||||
| 182 | $form->assign($xoopsTpl); |
||||
| 183 | $xoopsTpl->assign('lang_close', _CLOSE); |
||||
| 184 | $xoopsTpl->display('db:system_imagemanager2.tpl'); |
||||
| 185 | exit(); |
||||
| 186 | } |
||||
| 187 | |||||
| 188 | if ('doupload' === $op) { |
||||
| 189 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||||
| 190 | $imgcatHandler = xoops_getHandler('imagecategory'); |
||||
| 191 | $imgcat = $imgcatHandler->get((int)$imgcat_id); |
||||
| 192 | $error = false; |
||||
| 193 | if (!is_object($imgcat)) { |
||||
| 194 | $error = true; |
||||
| 195 | } else { |
||||
| 196 | $imgcatpermHandler = xoops_getHandler('groupperm'); |
||||
| 197 | if ($xoopsUser) { |
||||
| 198 | if (!$imgcatpermHandler->checkRight('imgcat_write', $imgcat_id, $xoopsUser->getGroups())) { |
||||
| 199 | $error = true; |
||||
| 200 | } |
||||
| 201 | } else { |
||||
| 202 | if (!$imgcatpermHandler->checkRight('imgcat_write', $imgcat_id, XOOPS_GROUP_ANONYMOUS)) { |
||||
| 203 | $error = true; |
||||
| 204 | } |
||||
| 205 | } |
||||
| 206 | } |
||||
| 207 | if (false !== $error) { |
||||
| 208 | xoops_header(false); |
||||
| 209 | echo '</head><body><div style="text-align:center;"><input value="' . _BACK . '" type="button" onclick="javascript:history.go(-1);"></div>'; |
||||
| 210 | xoops_footer(); |
||||
| 211 | exit(); |
||||
| 212 | } |
||||
| 213 | $uploader = new \XoopsMediaUploader(XOOPS_UPLOAD_PATH, ['image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'], $imgcat->getVar('imgcat_maxsize'), $imgcat->getVar('imgcat_maxwidth'), $imgcat->getVar('imgcat_maxheight')); |
||||
| 214 | $uploader->setPrefix('img'); |
||||
| 215 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
||||
| 216 | if (!$uploader->upload()) { |
||||
| 217 | $err = $uploader->getErrors(); |
||||
| 218 | } else { |
||||
| 219 | $imageHandler = xoops_getHandler('image'); |
||||
| 220 | $image = $imageHandler->create(); |
||||
| 221 | $image->setVar('image_name', $uploader->getSavedFileName()); |
||||
| 222 | $image->setVar('image_nicename', $image_nicename); |
||||
| 223 | $image->setVar('image_mimetype', $uploader->getMediaType()); |
||||
| 224 | $image->setVar('image_created', time()); |
||||
| 225 | $image->setVar('image_display', 1); |
||||
| 226 | $image->setVar('image_weight', 0); |
||||
| 227 | $image->setVar('imgcat_id', $imgcat_id); |
||||
| 228 | if ('db' === $imgcat->getVar('imgcat_storetype')) { |
||||
| 229 | $fp = @fopen($uploader->getSavedDestination(), 'rb'); |
||||
| 230 | $fbinary = @fread($fp, filesize($uploader->getSavedDestination())); |
||||
| 231 | @fclose($fp); |
||||
|
0 ignored issues
–
show
|
|||||
| 232 | $image->setVar('image_body', addslashes($fbinary)); |
||||
| 233 | @unlink($uploader->getSavedDestination()); |
||||
|
0 ignored issues
–
show
It seems like you do not handle an error condition for
unlink(). This can introduce security issues, and is generally not recommended.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
|
|||||
| 234 | } |
||||
| 235 | if (!$imageHandler->insert($image)) { |
||||
| 236 | $err = sprintf(_FAILSAVEIMG, $image->getVar('image_nicename')); |
||||
| 237 | } |
||||
| 238 | } |
||||
| 239 | } else { |
||||
| 240 | $err = _FAILFETCHIMG; |
||||
| 241 | } |
||||
| 242 | if (isset($err)) { |
||||
| 243 | xoops_header(false); |
||||
| 244 | xoops_error($err); |
||||
| 245 | echo '</head><body><div style="text-align:center;"><input value="' . _BACK . '" type="button" onclick="javascript:history.go(-1);"></div>'; |
||||
| 246 | xoops_footer(); |
||||
| 247 | exit(); |
||||
| 248 | } |
||||
| 249 | header('location: imagemanager.php?cat_id=' . $imgcat_id . '&target=' . $target); |
||||
| 250 | } |
||||
| 251 |
If you suppress an error, we recommend checking for the error condition explicitly: