txmodxoops /
tdmcreate
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\Mymodule3; |
||||||
| 4 | |||||||
| 5 | /* |
||||||
| 6 | You may not change or alter any portion of this comment or credits |
||||||
| 7 | of supporting developers from this source code or any supporting source code |
||||||
| 8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
| 9 | |||||||
| 10 | This program is distributed in the hope that it will be useful, |
||||||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 13 | */ |
||||||
| 14 | |||||||
| 15 | /** |
||||||
| 16 | * My Module 3 module for xoops |
||||||
| 17 | * |
||||||
| 18 | * @copyright 2020 XOOPS Project (https://xooops.org) |
||||||
| 19 | * @license GPL 2.0 or later |
||||||
| 20 | * @package mymodule3 |
||||||
| 21 | * @since 1.0 |
||||||
| 22 | * @min_xoops 2.5.9 |
||||||
| 23 | * @author TDM XOOPS - Email:<[email protected]> - Website:<http://xoops.org> |
||||||
| 24 | */ |
||||||
| 25 | |||||||
| 26 | use XoopsModules\Mymodule3; |
||||||
| 27 | |||||||
| 28 | defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||||||
| 29 | |||||||
| 30 | /** |
||||||
| 31 | * Class Object Articles |
||||||
| 32 | */ |
||||||
| 33 | class Articles extends \XoopsObject |
||||||
| 34 | { |
||||||
| 35 | /** |
||||||
| 36 | * Constructor |
||||||
| 37 | * |
||||||
| 38 | * @param null |
||||||
| 39 | */ |
||||||
| 40 | public function __construct() |
||||||
| 41 | { |
||||||
| 42 | $this->initVar('art_id', XOBJ_DTYPE_INT); |
||||||
| 43 | $this->initVar('art_cat', XOBJ_DTYPE_INT); |
||||||
| 44 | $this->initVar('art_title', XOBJ_DTYPE_TXTBOX); |
||||||
| 45 | $this->initVar('art_descr', XOBJ_DTYPE_TXTAREA); |
||||||
| 46 | $this->initVar('art_img', XOBJ_DTYPE_TXTBOX); |
||||||
| 47 | $this->initVar('art_online', XOBJ_DTYPE_INT); |
||||||
| 48 | $this->initVar('art_file', XOBJ_DTYPE_TXTBOX); |
||||||
| 49 | $this->initVar('art_created', XOBJ_DTYPE_INT); |
||||||
| 50 | $this->initVar('art_submitter', XOBJ_DTYPE_INT); |
||||||
| 51 | } |
||||||
| 52 | |||||||
| 53 | /** |
||||||
| 54 | * @static function &getInstance |
||||||
| 55 | * |
||||||
| 56 | * @param null |
||||||
| 57 | */ |
||||||
| 58 | public static function getInstance() |
||||||
| 59 | { |
||||||
| 60 | static $instance = false; |
||||||
| 61 | if (!$instance) { |
||||||
| 62 | $instance = new self(); |
||||||
| 63 | } |
||||||
| 64 | } |
||||||
| 65 | |||||||
| 66 | /** |
||||||
| 67 | * The new inserted $Id |
||||||
| 68 | * @return inserted id |
||||||
|
0 ignored issues
–
show
|
|||||||
| 69 | */ |
||||||
| 70 | public function getNewInsertedIdArticles() |
||||||
| 71 | { |
||||||
| 72 | $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
||||||
| 73 | return $newInsertedId; |
||||||
| 74 | } |
||||||
| 75 | |||||||
| 76 | /** |
||||||
| 77 | * @public function getForm |
||||||
| 78 | * @param bool $action |
||||||
| 79 | * @return \XoopsThemeForm |
||||||
| 80 | */ |
||||||
| 81 | public function getFormArticles($action = false) |
||||||
| 82 | { |
||||||
| 83 | $helper = \XoopsModules\Mymodule3\Helper::getInstance(); |
||||||
| 84 | if (false === $action) { |
||||||
| 85 | $action = $_SERVER['REQUEST_URI']; |
||||||
| 86 | } |
||||||
| 87 | // Permissions for uploader |
||||||
| 88 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||||
| 89 | $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||||||
| 90 | if ($GLOBALS['xoopsUser']) { |
||||||
| 91 | if (!$GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) { |
||||||
| 92 | $permissionUpload = $grouppermHandler->checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false; |
||||||
|
0 ignored issues
–
show
The method
checkRight() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 93 | } else { |
||||||
| 94 | $permissionUpload = true; |
||||||
| 95 | } |
||||||
| 96 | } else { |
||||||
| 97 | $permissionUpload = $grouppermHandler->checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false; |
||||||
| 98 | } |
||||||
| 99 | // Title |
||||||
| 100 | $title = $this->isNew() ? sprintf(_AM_MYMODULE3_ARTICLE_ADD) : sprintf(_AM_MYMODULE3_ARTICLE_EDIT); |
||||||
| 101 | // Get Theme Form |
||||||
| 102 | xoops_load('XoopsFormLoader'); |
||||||
| 103 | $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
||||||
| 104 | $form->setExtra('enctype="multipart/form-data"'); |
||||||
| 105 | // Use tag module |
||||||
| 106 | $dirTag = is_dir(XOOPS_ROOT_PATH . '/modules/tag') ? true : false; |
||||||
| 107 | if (($helper->getConfig('usetag') == 1) && $dirTag) { |
||||||
| 108 | $tagId = $this->isNew() ? 0 : $this->getVar('art_id'); |
||||||
| 109 | include_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php'; |
||||||
| 110 | $form->addElement(new \XoopsFormTag( 'tag', 60, 255, $tagId, 0 ), true); |
||||||
|
0 ignored issues
–
show
It seems like
$tagId can also be of type array and array; however, parameter $value of XoopsFormTag::__construct() does only seem to accept integer|string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 111 | } |
||||||
| 112 | // Form Table categories |
||||||
| 113 | $categoriesHandler = $helper->getHandler('categories'); |
||||||
| 114 | $artCatSelect = new \XoopsFormSelect( _AM_MYMODULE3_ARTICLE_CAT, 'art_cat', $this->getVar('art_cat')); |
||||||
| 115 | $artCatSelect->addOptionArray($categoriesHandler->getList()); |
||||||
|
0 ignored issues
–
show
The method
getList() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsImageHandler or XoopsRankHandler or XoopsCommentHandler or XoopsTplsetHandler or XoopsAvatarHandler or XoopsBlockHandler or XoopsImagesetHandler or XoopsPersistableObjectHandler or XoopsImagecategoryHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 116 | $form->addElement($artCatSelect, true); |
||||||
| 117 | // Form Text artTitle |
||||||
| 118 | $form->addElement(new \XoopsFormText( _AM_MYMODULE3_ARTICLE_TITLE, 'art_title', 50, 255, $this->getVar('art_title') ), true); |
||||||
|
0 ignored issues
–
show
It seems like
$this->getVar('art_title') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 119 | // Form Editor DhtmlTextArea artDescr |
||||||
| 120 | $editorConfigs = []; |
||||||
| 121 | $editorConfigs['name'] = 'art_descr'; |
||||||
| 122 | $editorConfigs['value'] = $this->getVar('art_descr', 'e'); |
||||||
| 123 | $editorConfigs['rows'] = 5; |
||||||
| 124 | $editorConfigs['cols'] = 40; |
||||||
| 125 | $editorConfigs['width'] = '100%'; |
||||||
| 126 | $editorConfigs['height'] = '400px'; |
||||||
| 127 | $editorConfigs['editor'] = $helper->getConfig('editor_descr'); |
||||||
| 128 | $form->addElement(new \XoopsFormEditor( _AM_MYMODULE3_ARTICLE_DESCR, 'art_descr', $editorConfigs), true); |
||||||
| 129 | // Form Image artImg |
||||||
| 130 | // Form Image artImg: Select Uploaded Image |
||||||
| 131 | $getArtImg = $this->getVar('art_img'); |
||||||
| 132 | $artImg = $getArtImg ? $getArtImg : 'blank.gif'; |
||||||
| 133 | $imageDirectory = '/uploads/mymodule3/images/articles'; |
||||||
| 134 | $imageTray = new \XoopsFormElementTray(_AM_MYMODULE3_ARTICLE_IMG, '<br>' ); |
||||||
| 135 | $imageSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE3_ARTICLE_IMG_UPLOADS, ".{$imageDirectory}/"), 'art_img', $artImg, 5); |
||||||
| 136 | $imageArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $imageDirectory ); |
||||||
| 137 | foreach($imageArray as $image1) { |
||||||
| 138 | $imageSelect->addOption("{$image1}", $image1); |
||||||
| 139 | } |
||||||
| 140 | $imageSelect->setExtra("onchange='showImgSelected(\"imglabel_art_img\", \"art_img\", \"" . $imageDirectory . "\", \"\", \"" . XOOPS_URL . "\")'"); |
||||||
| 141 | $imageTray->addElement($imageSelect, false); |
||||||
| 142 | $imageTray->addElement(new \XoopsFormLabel('', "<br><img src='" . XOOPS_URL . "/" . $imageDirectory . "/" . $artImg . "' id='imglabel_art_img' alt='' style='max-width:100px' />")); |
||||||
| 143 | // Form Image artImg: Upload new image |
||||||
| 144 | if ($permissionUpload) { |
||||||
| 145 | $maxsize = $helper->getConfig('maxsize_image'); |
||||||
| 146 | $imageTray->addElement(new \XoopsFormFile( '<br>' . _AM_MYMODULE3_FORM_UPLOAD_NEW, 'art_img', $maxsize )); |
||||||
| 147 | $imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE3_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . _AM_MYMODULE3_FORM_UPLOAD_SIZE_MB)); |
||||||
| 148 | $imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE3_FORM_UPLOAD_IMG_WIDTH, $helper->getConfig('maxwidth_image') . ' px')); |
||||||
| 149 | $imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE3_FORM_UPLOAD_IMG_HEIGHT, $helper->getConfig('maxheight_image') . ' px')); |
||||||
| 150 | } else { |
||||||
| 151 | $imageTray->addElement(new \XoopsFormHidden( 'art_img', $artImg )); |
||||||
| 152 | } |
||||||
| 153 | $form->addElement($imageTray, ); |
||||||
| 154 | // Form Radio Yes/No artOnline |
||||||
| 155 | $artOnline = $this->isNew() ? 0 : $this->getVar('art_online'); |
||||||
| 156 | $form->addElement(new \XoopsFormRadioYN( _AM_MYMODULE3_ARTICLE_ONLINE, 'art_online', $artOnline), true); |
||||||
|
0 ignored issues
–
show
It seems like
$artOnline can also be of type array and array; however, parameter $value of XoopsFormRadioYN::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 157 | // Form File Upload artFile |
||||||
| 158 | $artFile = $this->isNew() ? '' : $this->getVar('art_file'); |
||||||
| 159 | if ($permissionUpload) { |
||||||
| 160 | $fileUploadTray = new \XoopsFormElementTray(_AM_MYMODULE3_ARTICLE_FILE, '<br>' ); |
||||||
| 161 | $fileDirectory = '/uploads/mymodule3/files/articles'; |
||||||
| 162 | if (!$this->isNew()) { |
||||||
| 163 | $fileUploadTray->addElement(new \XoopsFormLabel(sprintf(_AM_MYMODULE3_ARTICLE_FILE_UPLOADS, ".{$fileDirectory}/"), $artFile)); |
||||||
|
0 ignored issues
–
show
It seems like
$artFile can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 164 | } |
||||||
| 165 | $maxsize = $helper->getConfig('maxsize_file'); |
||||||
| 166 | $fileUploadTray->addElement(new \XoopsFormFile( '', 'art_file', $maxsize )); |
||||||
| 167 | $fileUploadTray->addElement(new \XoopsFormLabel(_AM_MYMODULE3_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . _AM_MYMODULE3_FORM_UPLOAD_SIZE_MB)); |
||||||
| 168 | $form->addElement($fileUploadTray, ); |
||||||
| 169 | } else { |
||||||
| 170 | $form->addElement(new \XoopsFormHidden( 'art_file', $artFile )); |
||||||
|
0 ignored issues
–
show
It seems like
$artFile can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 171 | } |
||||||
| 172 | // Form Text Date Select artCreated |
||||||
| 173 | $artCreated = $this->isNew() ? 0 : $this->getVar('art_created'); |
||||||
| 174 | $form->addElement(new \XoopsFormTextDateSelect( _AM_MYMODULE3_ARTICLE_CREATED, 'art_created', '', $artCreated )); |
||||||
|
0 ignored issues
–
show
'' of type string is incompatible with the type integer expected by parameter $size of XoopsFormTextDateSelect::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 175 | // Form Select User artSubmitter |
||||||
| 176 | $form->addElement(new \XoopsFormSelectUser( _AM_MYMODULE3_ARTICLE_SUBMITTER, 'art_submitter', false, $this->getVar('art_submitter') )); |
||||||
| 177 | // Permissions |
||||||
| 178 | $memberHandler = xoops_getHandler('member'); |
||||||
| 179 | $groupList = $memberHandler->getGroupList(); |
||||||
|
0 ignored issues
–
show
The method
getGroupList() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 180 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||||
| 181 | $fullList[] = array_keys($groupList); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 182 | if (!$this->isNew()) { |
||||||
| 183 | $groupsIdsApprove = $grouppermHandler->getGroupIds('mymodule3_approve_articles', $this->getVar('art_id'), $GLOBALS['xoopsModule']->getVar('mid')); |
||||||
|
0 ignored issues
–
show
The method
getGroupIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 184 | $groupsIdsApprove[] = array_values($groupsIdsApprove); |
||||||
| 185 | $groupsCanApproveCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE3_PERMISSIONS_APPROVE, 'groups_approve_articles[]', $groupsIdsApprove); |
||||||
| 186 | $groupsIdsSubmit = $grouppermHandler->getGroupIds('mymodule3_submit_articles', $this->getVar('art_id'), $GLOBALS['xoopsModule']->getVar('mid')); |
||||||
| 187 | $groupsIdsSubmit[] = array_values($groupsIdsSubmit); |
||||||
| 188 | $groupsCanSubmitCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE3_PERMISSIONS_SUBMIT, 'groups_submit_articles[]', $groupsIdsSubmit); |
||||||
| 189 | $groupsIdsView = $grouppermHandler->getGroupIds('mymodule3_view_articles', $this->getVar('art_id'), $GLOBALS['xoopsModule']->getVar('mid')); |
||||||
| 190 | $groupsIdsView[] = array_values($groupsIdsView); |
||||||
| 191 | $groupsCanViewCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE3_PERMISSIONS_VIEW, 'groups_view_articles[]', $groupsIdsView); |
||||||
| 192 | } else { |
||||||
| 193 | $groupsCanApproveCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE3_PERMISSIONS_APPROVE, 'groups_approve_articles[]', $fullList); |
||||||
| 194 | $groupsCanSubmitCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE3_PERMISSIONS_SUBMIT, 'groups_submit_articles[]', $fullList); |
||||||
| 195 | $groupsCanViewCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE3_PERMISSIONS_VIEW, 'groups_view_articles[]', $fullList); |
||||||
| 196 | } |
||||||
| 197 | // To Approve |
||||||
| 198 | $groupsCanApproveCheckbox->addOptionArray($groupList); |
||||||
| 199 | $form->addElement($groupsCanApproveCheckbox); |
||||||
| 200 | // To Submit |
||||||
| 201 | $groupsCanSubmitCheckbox->addOptionArray($groupList); |
||||||
| 202 | $form->addElement($groupsCanSubmitCheckbox); |
||||||
| 203 | // To View |
||||||
| 204 | $groupsCanViewCheckbox->addOptionArray($groupList); |
||||||
| 205 | $form->addElement($groupsCanViewCheckbox); |
||||||
| 206 | // To Save |
||||||
| 207 | $form->addElement(new \XoopsFormHidden('op', 'save')); |
||||||
| 208 | $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
||||||
| 209 | return $form; |
||||||
| 210 | } |
||||||
| 211 | |||||||
| 212 | /** |
||||||
| 213 | * Get Values |
||||||
| 214 | * @param null $keys |
||||||
|
0 ignored issues
–
show
|
|||||||
| 215 | * @param null $format |
||||||
|
0 ignored issues
–
show
|
|||||||
| 216 | * @param null$maxDepth |
||||||
| 217 | * @return array |
||||||
| 218 | */ |
||||||
| 219 | public function getValuesArticles($keys = null, $format = null, $maxDepth = null) |
||||||
| 220 | { |
||||||
| 221 | $helper = \XoopsModules\Mymodule3\Helper::getInstance(); |
||||||
| 222 | $ret = $this->getValues($keys, $format, $maxDepth); |
||||||
| 223 | $ret['id'] = $this->getVar('art_id'); |
||||||
| 224 | $categoriesHandler = $helper->getHandler('categories'); |
||||||
| 225 | $categoriesObj = $categoriesHandler->get($this->getVar('art_cat')); |
||||||
| 226 | $ret['cat'] = $categoriesObj->getVar('cat_name'); |
||||||
| 227 | $ret['title'] = $this->getVar('art_title'); |
||||||
| 228 | $ret['descr'] = strip_tags($this->getVar('art_descr')); |
||||||
|
0 ignored issues
–
show
It seems like
$this->getVar('art_descr') can also be of type array and array; however, parameter $str of strip_tags() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 229 | $ret['img'] = $this->getVar('art_img'); |
||||||
| 230 | $ret['online'] = (int)$this->getVar('art_online') > 0 ? _YES : _NO; |
||||||
| 231 | $ret['file'] = $this->getVar('art_file'); |
||||||
| 232 | $ret['created'] = formatTimeStamp($this->getVar('art_created'), 's'); |
||||||
| 233 | $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('art_submitter')); |
||||||
| 234 | return $ret; |
||||||
| 235 | } |
||||||
| 236 | |||||||
| 237 | /** |
||||||
| 238 | * Returns an array representation of the object |
||||||
| 239 | * |
||||||
| 240 | * @return array |
||||||
| 241 | */ |
||||||
| 242 | public function toArrayArticles() |
||||||
| 243 | { |
||||||
| 244 | $ret = []; |
||||||
| 245 | $vars = $this->getVars(); |
||||||
| 246 | foreach(array_keys($vars) as $var) { |
||||||
| 247 | $ret[$var] = $this->getVar('"{$var}"'); |
||||||
| 248 | } |
||||||
| 249 | return $ret; |
||||||
| 250 | } |
||||||
| 251 | } |
||||||
| 252 |
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.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths