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 | 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 | * My Module module for xoops |
||||||
| 14 | * |
||||||
| 15 | * @copyright 2020 XOOPS Project (https://xooops.org) |
||||||
| 16 | * @license GPL 2.0 or later |
||||||
| 17 | * @package mymodule |
||||||
| 18 | * @since 1.0 |
||||||
| 19 | * @min_xoops 2.5.9 |
||||||
| 20 | * @author TDM XOOPS - Email:<[email protected]> - Website:<http://xoops.org> |
||||||
| 21 | */ |
||||||
| 22 | |||||||
| 23 | /***************Blocks***************/ |
||||||
| 24 | |||||||
| 25 | /** |
||||||
| 26 | * add selected cats |
||||||
| 27 | * @param $cats |
||||||
| 28 | * @return string |
||||||
| 29 | */ |
||||||
| 30 | function mymodule_block_addCatSelect($cats) { |
||||||
| 31 | if(is_array($cats)) |
||||||
| 32 | { |
||||||
| 33 | $cat_sql = '('.current($cats); |
||||||
| 34 | array_shift($cats); |
||||||
| 35 | foreach($cats as $cat) |
||||||
| 36 | { |
||||||
| 37 | $cat_sql .= ','.$cat; |
||||||
| 38 | } |
||||||
| 39 | $cat_sql .= ')'; |
||||||
| 40 | } |
||||||
| 41 | return $cat_sql; |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||||||
| 42 | } |
||||||
| 43 | |||||||
| 44 | /** |
||||||
| 45 | * Get the permissions ids |
||||||
| 46 | * @param $permtype |
||||||
| 47 | * @param $dirname |
||||||
| 48 | * @return mixed $articles |
||||||
| 49 | */ |
||||||
| 50 | function mymoduleGetMyItemIds($permtype, $dirname) |
||||||
| 51 | { |
||||||
| 52 | global $xoopsUser; |
||||||
| 53 | static $permissions = array(); |
||||||
| 54 | if(is_array($permissions) && array_key_exists($permtype, $permissions)) { |
||||||
| 55 | return $permissions[$permtype]; |
||||||
| 56 | } |
||||||
| 57 | $moduleHandler = xoops_getHandler('module'); |
||||||
| 58 | $mymoduleModule = $moduleHandler->getByDirname($dirname); |
||||||
|
0 ignored issues
–
show
The method
getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 59 | $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||||||
| 60 | $gpermHandler = xoops_getHandler('groupperm'); |
||||||
| 61 | $articles = $gpermHandler->getItemIds($permtype, $groups, $mymoduleModule->getVar('mid')); |
||||||
|
0 ignored issues
–
show
The method
getItemIds() 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...
|
|||||||
| 62 | return $articles; |
||||||
| 63 | } |
||||||
| 64 | |||||||
| 65 | /** |
||||||
| 66 | * Get the number of articles from the sub categories of a category or sub topics of or topic |
||||||
| 67 | * @param $mytree |
||||||
| 68 | * @param $articles |
||||||
| 69 | * @param $entries |
||||||
| 70 | * @param $cid |
||||||
| 71 | * @return int |
||||||
| 72 | */ |
||||||
| 73 | function mymoduleNumbersOfEntries($mytree, $articles, $entries, $cid) |
||||||
| 74 | { |
||||||
| 75 | $count = 0; |
||||||
| 76 | if(in_array($cid, $articles)) { |
||||||
| 77 | $child = $mytree->getAllChild($cid); |
||||||
| 78 | foreach (array_keys($entries) as $i) { |
||||||
| 79 | if ($entries[$i]->getVar('art_id') == $cid){ |
||||||
| 80 | $count++; |
||||||
| 81 | } |
||||||
| 82 | foreach (array_keys($child) as $j) { |
||||||
| 83 | if ($entries[$i]->getVar('art_id') == $j){ |
||||||
| 84 | $count++; |
||||||
| 85 | } |
||||||
| 86 | } |
||||||
| 87 | } |
||||||
| 88 | } |
||||||
| 89 | return $count; |
||||||
| 90 | } |
||||||
| 91 | |||||||
| 92 | /** |
||||||
| 93 | * Add content as meta tag to template |
||||||
| 94 | * @param $content |
||||||
| 95 | * @return void |
||||||
| 96 | */ |
||||||
| 97 | |||||||
| 98 | function mymoduleMetaKeywords($content) |
||||||
| 99 | { |
||||||
| 100 | global $xoopsTpl, $xoTheme; |
||||||
| 101 | $myts = MyTextSanitizer::getInstance(); |
||||||
| 102 | $content= $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
||||||
| 103 | if(isset($xoTheme) && is_object($xoTheme)) { |
||||||
| 104 | $xoTheme->addMeta( 'meta', 'keywords', strip_tags($content)); |
||||||
| 105 | } else { // Compatibility for old Xoops versions |
||||||
| 106 | $xoopsTpl->assign('xoops_meta_keywords', strip_tags($content)); |
||||||
| 107 | } |
||||||
| 108 | } |
||||||
| 109 | |||||||
| 110 | /** |
||||||
| 111 | * Add content as meta description to template |
||||||
| 112 | * @param $content |
||||||
| 113 | * @return void |
||||||
| 114 | */ |
||||||
| 115 | |||||||
| 116 | function mymoduleMetaDescription($content) |
||||||
| 117 | { |
||||||
| 118 | global $xoopsTpl, $xoTheme; |
||||||
| 119 | $myts = MyTextSanitizer::getInstance(); |
||||||
| 120 | $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
||||||
| 121 | if(isset($xoTheme) && is_object($xoTheme)) { |
||||||
| 122 | $xoTheme->addMeta( 'meta', 'description', strip_tags($content)); |
||||||
| 123 | } else { // Compatibility for old Xoops versions |
||||||
| 124 | $xoopsTpl->assign('xoops_meta_description', strip_tags($content)); |
||||||
| 125 | } |
||||||
| 126 | } |
||||||
| 127 | |||||||
| 128 | /** |
||||||
| 129 | * Rewrite all url |
||||||
| 130 | * |
||||||
| 131 | * @param string $module module name |
||||||
| 132 | * @param array $array array |
||||||
| 133 | * @param string $type type |
||||||
| 134 | * @return null|string $type string replacement for any blank case |
||||||
| 135 | */ |
||||||
| 136 | function mymodule_RewriteUrl($module, $array, $type = 'content') |
||||||
| 137 | { |
||||||
| 138 | $comment = ''; |
||||||
| 139 | $helper = \XoopsModules\Mymodule\Helper::getInstance(); |
||||||
| 140 | $articles = $helper->getHandler('articles'); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 141 | $lenght_id = $helper->getConfig('lenght_id'); |
||||||
| 142 | $rewrite_url = $helper->getConfig('rewrite_url'); |
||||||
| 143 | |||||||
| 144 | if ($lenght_id != 0) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 145 | $id = $array['content_id']; |
||||||
| 146 | while (strlen($id) < $lenght_id) { |
||||||
| 147 | $id = '0' . $id; |
||||||
| 148 | } |
||||||
| 149 | } else { |
||||||
| 150 | $id = $array['content_id']; |
||||||
| 151 | } |
||||||
| 152 | |||||||
| 153 | if (isset($array['topic_alias']) && $array['topic_alias']) { |
||||||
| 154 | $topic_name = $array['topic_alias']; |
||||||
| 155 | } else { |
||||||
| 156 | $topic_name = mymodule_Filter(xoops_getModuleOption('static_name', $module)); |
||||||
|
0 ignored issues
–
show
The function
xoops_getModuleOption() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 157 | } |
||||||
| 158 | |||||||
| 159 | switch ($rewrite_url) { |
||||||
| 160 | |||||||
| 161 | case 'none': |
||||||
| 162 | if($topic_name) { |
||||||
| 163 | $topic_name = 'topic=' . $topic_name . '&'; |
||||||
| 164 | } |
||||||
| 165 | $rewrite_base = '/modules/'; |
||||||
| 166 | $page = 'page=' . $array['content_alias']; |
||||||
| 167 | return XOOPS_URL . $rewrite_base . $module . '/' . $type . '.php?' . $topic_name . 'id=' . $id . '&' . $page . $comment; |
||||||
| 168 | break; |
||||||
|
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other Loading history...
|
|||||||
| 169 | |||||||
| 170 | case 'rewrite': |
||||||
| 171 | if($topic_name) { |
||||||
| 172 | $topic_name .= '/'; |
||||||
| 173 | } |
||||||
| 174 | $rewrite_base = xoops_getModuleOption('rewrite_mode', $module); |
||||||
|
0 ignored issues
–
show
The function
xoops_getModuleOption() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 175 | $rewrite_ext = xoops_getModuleOption('rewrite_ext', $module); |
||||||
|
0 ignored issues
–
show
The function
xoops_getModuleOption() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 176 | $module_name = ''; |
||||||
| 177 | if(xoops_getModuleOption('rewrite_name', $module)) { |
||||||
|
0 ignored issues
–
show
The function
xoops_getModuleOption() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 178 | $module_name = xoops_getModuleOption('rewrite_name', $module) . '/'; |
||||||
|
0 ignored issues
–
show
The function
xoops_getModuleOption() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 179 | } |
||||||
| 180 | $page = $array['content_alias']; |
||||||
| 181 | $type .= '/'; |
||||||
| 182 | $id .= '/'; |
||||||
| 183 | if ($type === 'content/') { |
||||||
| 184 | $type = ''; |
||||||
| 185 | } |
||||||
| 186 | if ($type === 'comment-edit/' || $type === 'comment-reply/' || $type === 'comment-delete/') { |
||||||
| 187 | return XOOPS_URL . $rewrite_base . $module_name . $type . $id . '/'; |
||||||
| 188 | } |
||||||
| 189 | |||||||
| 190 | return XOOPS_URL . $rewrite_base . $module_name . $type . $topic_name . $id . $page . $rewrite_ext; |
||||||
| 191 | break; |
||||||
| 192 | |||||||
| 193 | case 'short': |
||||||
| 194 | if($topic_name) { |
||||||
| 195 | $topic_name .= '/'; |
||||||
| 196 | } |
||||||
| 197 | $rewrite_base = xoops_getModuleOption('rewrite_mode', $module); |
||||||
|
0 ignored issues
–
show
The function
xoops_getModuleOption() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 198 | $rewrite_ext = xoops_getModuleOption('rewrite_ext', $module); |
||||||
|
0 ignored issues
–
show
The function
xoops_getModuleOption() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 199 | $module_name = ''; |
||||||
| 200 | if(xoops_getModuleOption('rewrite_name', $module)) { |
||||||
|
0 ignored issues
–
show
The function
xoops_getModuleOption() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 201 | $module_name = xoops_getModuleOption('rewrite_name', $module) . '/'; |
||||||
|
0 ignored issues
–
show
The function
xoops_getModuleOption() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 202 | } |
||||||
| 203 | $page = $array['content_alias']; |
||||||
| 204 | $type .= '/'; |
||||||
| 205 | if ($type === 'content/') { |
||||||
| 206 | $type = ''; |
||||||
| 207 | } |
||||||
| 208 | if ($type === 'comment-edit/' || $type === 'comment-reply/' || $type === 'comment-delete/') { |
||||||
| 209 | return XOOPS_URL . $rewrite_base . $module_name . $type . $id . '/'; |
||||||
| 210 | } |
||||||
| 211 | |||||||
| 212 | return XOOPS_URL . $rewrite_base . $module_name . $type . $topic_name . $page . $rewrite_ext; |
||||||
| 213 | break; |
||||||
| 214 | } |
||||||
| 215 | return null; |
||||||
| 216 | } |
||||||
| 217 | /** |
||||||
| 218 | * Replace all escape, character, ... for display a correct url |
||||||
| 219 | * |
||||||
| 220 | * @param string $url string to transform |
||||||
| 221 | * @param string $type string replacement for any blank case |
||||||
| 222 | * @return string $url |
||||||
| 223 | */ |
||||||
| 224 | function mymodule_Filter($url, $type = '') { |
||||||
| 225 | |||||||
| 226 | // Get regular expression from module setting. default setting is : `[^a-z0-9]`i |
||||||
| 227 | $helper = \XoopsModules\Mymodule\Helper::getInstance(); |
||||||
| 228 | $articles = $helper->getHandler('articles'); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 229 | $regular_expression = $helper->getConfig('regular_expression'); |
||||||
| 230 | |||||||
| 231 | $url = strip_tags($url); |
||||||
| 232 | $url .= preg_replace("`\[.*\]`U", '', $url); |
||||||
| 233 | $url .= preg_replace('`&(amp;)?#?[a-z0-9]+;`i', '-', $url); |
||||||
| 234 | $url .= htmlentities($url, ENT_COMPAT, 'utf-8'); |
||||||
| 235 | $url .= preg_replace("`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i", "\1", $url); |
||||||
| 236 | $url .= preg_replace(array($regular_expression, "`[-]+`"), '-', $url); |
||||||
| 237 | $url = ($url == '') ? $type : strtolower(trim($url, '-')); |
||||||
| 238 | return $url; |
||||||
| 239 | } |