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\Mymodule; |
||||
| 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 module for xoops |
||||
| 17 | * |
||||
| 18 | * @copyright 2020 XOOPS Project (https://xooops.org) |
||||
| 19 | * @license GPL 2.0 or later |
||||
| 20 | * @package mymodule |
||||
| 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\Mymodule; |
||||
| 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 |
||||
|
0 ignored issues
–
show
|
|||||
| 80 | */ |
||||
| 81 | public function getFormArticles($action = false) |
||||
| 82 | { |
||||
| 83 | $helper = \XoopsModules\Mymodule\Helper::getInstance(); |
||||
| 84 | if(false === $action) { |
||||
| 85 | $action = $_SERVER['REQUEST_URI']; |
||||
| 86 | } |
||||
| 87 | // Permissions for uploader |
||||
| 88 | $gpermHandler = 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 = $gpermHandler->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 = $gpermHandler->checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false; |
||||
| 98 | } |
||||
| 99 | // Title |
||||
| 100 | $title = $this->isNew() ? sprintf(_AM_MYMODULE_ARTICLE_ADD) : sprintf(_AM_MYMODULE_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_MYMODULE_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_MYMODULE_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 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_MYMODULE_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/mymodule/images/articles'; |
||||
| 134 | $imageTray = new \XoopsFormElementTray(_AM_MYMODULE_FORM_UPLOAD, '<br>' ); |
||||
| 135 | $imageSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE_FORM_IMAGE_PATH, ".{$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(\"image1\", \"art_img\", \"".$imageDirectory."\", \"\", \"".XOOPS_URL."\")'"); |
||||
| 141 | $imageTray->addElement($imageSelect, false); |
||||
| 142 | $imageTray->addElement(new \XoopsFormLabel('', "<br><img src='".XOOPS_URL."/".$imageDirectory."/".$artImg."' name='image1' id='image1' alt='' style='max-width:100px' />")); |
||||
| 143 | // Form Image ArtImg: Upload Image |
||||
| 144 | if($permissionUpload) { |
||||
| 145 | $imageTray->addElement(new \XoopsFormFile( _AM_MYMODULE_FORM_UPLOAD_NEW, 'attachedfile', $helper->getConfig('maxsize') )); |
||||
| 146 | } else { |
||||
| 147 | $imageTray->addElement(new \XoopsFormHidden( 'art_img', $artImg )); |
||||
| 148 | } |
||||
| 149 | $form->addElement($imageTray); |
||||
| 150 | // Form Radio Yes/No ArtOnline |
||||
| 151 | $artOnline = $this->isNew() ? 0 : $this->getVar('art_online'); |
||||
| 152 | $form->addElement(new \XoopsFormRadioYN( _AM_MYMODULE_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...
|
|||||
| 153 | // Form File ArtFile |
||||
| 154 | $artFile = $this->isNew() ? '' : $this->getVar('art_file'); |
||||
| 155 | if($permissionUpload) { |
||||
| 156 | $fileUploadTray = new \XoopsFormElementTray(_AM_MYMODULE_FORM_UPLOAD, '<br>' ); |
||||
| 157 | if(!$this->isNew()) { |
||||
| 158 | $fileUploadTray->addElement(new \XoopsFormLabel(_AM_MYMODULE_FORM_UPLOAD_FILE_ARTICLES, $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...
|
|||||
| 159 | } |
||||
| 160 | $fileUploadTray->addElement(new \XoopsFormFile( '', 'art_file', $helper->getConfig('maxsize') )); |
||||
| 161 | $form->addElement($fileUploadTray); |
||||
| 162 | } else { |
||||
| 163 | $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...
|
|||||
| 164 | } |
||||
| 165 | // Form Text Date Select ArtCreated |
||||
| 166 | $artCreated = $this->isNew() ? 0 : $this->getVar('art_created'); |
||||
| 167 | $form->addElement(new \XoopsFormTextDateSelect( _AM_MYMODULE_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...
|
|||||
| 168 | // Form Select User ArtSubmitter |
||||
| 169 | $form->addElement(new \XoopsFormSelectUser( _AM_MYMODULE_ARTICLE_SUBMITTER, 'art_submitter', false, $this->getVar('art_submitter') )); |
||||
| 170 | // To Save |
||||
| 171 | $form->addElement(new \XoopsFormHidden('op', 'save')); |
||||
| 172 | $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
||||
| 173 | return $form; |
||||
|
0 ignored issues
–
show
|
|||||
| 174 | } |
||||
| 175 | |||||
| 176 | /** |
||||
| 177 | * Get Values |
||||
| 178 | * @param null $keys |
||||
|
0 ignored issues
–
show
|
|||||
| 179 | * @param null $format |
||||
|
0 ignored issues
–
show
|
|||||
| 180 | * @param null$maxDepth |
||||
| 181 | * @return array |
||||
| 182 | */ |
||||
| 183 | public function getValuesArticles($keys = null, $format = null, $maxDepth = null) |
||||
| 184 | { |
||||
| 185 | $helper = \XoopsModules\Mymodule\Helper::getInstance(); |
||||
| 186 | $ret = $this->getValues($keys, $format, $maxDepth); |
||||
| 187 | $ret['id'] = $this->getVar('art_id'); |
||||
| 188 | $categories = $helper->getHandler('categories'); |
||||
| 189 | $categoriesObj = $categories->get($this->getVar('art_cat')); |
||||
| 190 | $ret['cat'] = $categoriesObj->getVar('cat_name'); |
||||
| 191 | $ret['title'] = $this->getVar('art_title'); |
||||
| 192 | $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...
|
|||||
| 193 | $ret['img'] = $this->getVar('art_img'); |
||||
| 194 | $ret['online'] = $this->getVar('art_online'); |
||||
| 195 | $ret['file'] = $this->getVar('art_file'); |
||||
| 196 | $ret['created'] = formatTimeStamp($this->getVar('art_created'), 's'); |
||||
| 197 | $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('art_submitter')); |
||||
| 198 | return $ret; |
||||
| 199 | } |
||||
| 200 | |||||
| 201 | /** |
||||
| 202 | * Returns an array representation of the object |
||||
| 203 | * |
||||
| 204 | * @return array |
||||
| 205 | */ |
||||
| 206 | public function toArrayArticles() |
||||
| 207 | { |
||||
| 208 | $ret = []; |
||||
| 209 | $vars = $this->getVars(); |
||||
| 210 | foreach(array_keys($vars) as $var) { |
||||
| 211 | $ret[$var] = $this->getVar('"{$var}"'); |
||||
| 212 | } |
||||
| 213 | return $ret; |
||||
| 214 | } |
||||
| 215 | } |
||||
| 216 |
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