mambax7 /
newbb
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 declare(strict_types=1); |
||||||
| 2 | |||||||
| 3 | /** |
||||||
| 4 | * NewBB, the forum module for XOOPS project |
||||||
| 5 | * |
||||||
| 6 | * @copyright XOOPS Project (https://xoops.org) |
||||||
| 7 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||||||
| 8 | * @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
||||||
| 9 | * @since 4.00 |
||||||
| 10 | */ |
||||||
| 11 | |||||||
| 12 | use XoopsModules\Newbb\{ |
||||||
| 13 | Helper, |
||||||
| 14 | IconHandler |
||||||
| 15 | }; |
||||||
| 16 | |||||||
| 17 | /** @var IconHandler $iconHandler */ |
||||||
| 18 | defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php'; |
||||||
| 19 | define('NEWBB_FUNCTIONS_RENDER_LOADED', true); |
||||||
| 20 | |||||||
| 21 | if (!defined('NEWBB_FUNCTIONS_RENDER')) { |
||||||
| 22 | define('NEWBB_FUNCTIONS_RENDER', 1); |
||||||
| 23 | |||||||
| 24 | /* |
||||||
| 25 | * Sorry, we have to use the stupid solution unless there is an option in MyTextSanitizer:: htmlspecialchars(); |
||||||
| 26 | */ |
||||||
| 27 | /** |
||||||
| 28 | * @param string $text |
||||||
| 29 | * |
||||||
| 30 | * @return null|string |
||||||
| 31 | */ |
||||||
| 32 | function newbbhtmlspecialchars(string $text): ?string |
||||||
| 33 | { |
||||||
| 34 | return preg_replace(['/&/i', '/ /i'], ['&', '&nbsp;'], htmlspecialchars($text, ENT_QUOTES | ENT_HTML5)); |
||||||
| 35 | } |
||||||
| 36 | |||||||
| 37 | /** |
||||||
| 38 | * @param string $text |
||||||
| 39 | * @param int $html |
||||||
| 40 | * @param int $smiley |
||||||
| 41 | * @param int $xcode |
||||||
| 42 | * @param int $image |
||||||
| 43 | * @param int $br |
||||||
| 44 | * @return mixed |
||||||
| 45 | */ |
||||||
| 46 | function &newbbDisplayTarea(string &$text, int $html = 0, int $smiley = 1, int $xcode = 1, int $image = 1, int $br = 1) |
||||||
| 47 | { |
||||||
| 48 | global $myts; |
||||||
| 49 | |||||||
| 50 | if (1 !== $html) { |
||||||
| 51 | // html not allowed |
||||||
| 52 | $text = newbbhtmlspecialchars($text); |
||||||
| 53 | } |
||||||
| 54 | $text = $myts->codePreConv($text, $xcode); // Ryuji_edit(2003-11-18) |
||||||
| 55 | $text = $myts->makeClickable($text); |
||||||
| 56 | if (0 !== $smiley) { |
||||||
| 57 | // process smiley |
||||||
| 58 | $text = $myts->smiley($text); |
||||||
| 59 | } |
||||||
| 60 | if (0 !== $xcode) { |
||||||
| 61 | // decode xcode |
||||||
| 62 | if (0 !== $image) { |
||||||
| 63 | // image allowed |
||||||
| 64 | $text = $myts->xoopsCodeDecode($text); |
||||||
| 65 | } else { |
||||||
| 66 | // image not allowed |
||||||
| 67 | $text = $myts->xoopsCodeDecode($text, 0); |
||||||
| 68 | } |
||||||
| 69 | } |
||||||
| 70 | if (0 !== $br) { |
||||||
| 71 | $text = $myts->nl2Br($text); |
||||||
| 72 | } |
||||||
| 73 | $text = $myts->codeConv($text, $xcode, $image); // Ryuji_edit(2003-11-18) |
||||||
| 74 | |||||||
| 75 | return $text; |
||||||
| 76 | } |
||||||
| 77 | |||||||
| 78 | /** |
||||||
| 79 | * @param string $document |
||||||
| 80 | * @return string |
||||||
| 81 | */ |
||||||
| 82 | function newbbHtml2text(string $document): string |
||||||
| 83 | { |
||||||
| 84 | $text = strip_tags($document); |
||||||
| 85 | |||||||
| 86 | return $text; |
||||||
| 87 | } |
||||||
| 88 | |||||||
| 89 | /** |
||||||
| 90 | * Display forum button |
||||||
| 91 | * |
||||||
| 92 | * @param string $link |
||||||
| 93 | * @param string $button |
||||||
| 94 | * @param string $alt alt message |
||||||
| 95 | * @param bool $asImage true for image mode; false for text mode |
||||||
| 96 | * @param string $extra extra attribute for the button |
||||||
| 97 | * @return string |
||||||
| 98 | * @internal param string $image image/button name, without extension |
||||||
| 99 | */ |
||||||
| 100 | function newbbGetButton(string $link, string $button, string $alt = '', bool $asImage = true, string $extra = "class='forum_button'"): string |
||||||
| 101 | { |
||||||
| 102 | $button = "<input type='button' name='{$button}' {$extra} value='{$alt}' onclick='window.location.href={$link}' >"; |
||||||
| 103 | if ($asImage === false) { |
||||||
| 104 | $button = "<a href='{$link}' title='{$alt}' {$extra}>" . newbbDisplayImage($button, $alt, true) . '</a>'; |
||||||
| 105 | } |
||||||
| 106 | |||||||
| 107 | return $button; |
||||||
| 108 | } |
||||||
| 109 | |||||||
| 110 | /** |
||||||
| 111 | * Display forrum images |
||||||
| 112 | * |
||||||
| 113 | * @param string $image image name, without extension |
||||||
| 114 | * @param string $alt alt message |
||||||
| 115 | * @param bool $display true for return image anchor; faulse for assign to $xoopsTpl |
||||||
| 116 | * @param string $extra extra attribute for the image |
||||||
| 117 | * @return mixed |
||||||
| 118 | */ |
||||||
| 119 | function newbbDisplayImage(string $image, string $alt = '', bool $display = true, string $extra = "class='forum_icon'") |
||||||
| 120 | { |
||||||
| 121 | $iconHandler = newbbGetIconHandler(); |
||||||
| 122 | // START hacked by irmtfan |
||||||
| 123 | // to show text links instead of buttons - func_num_args()==2 => only when $image, $alt is set and optional $display not set |
||||||
| 124 | |||||||
| 125 | if (2 === func_num_args()) { |
||||||
| 126 | // overall setting |
||||||
| 127 | if (!empty($GLOBALS['xoopsModuleConfig']['display_text_links'])) { |
||||||
| 128 | $display = false; |
||||||
| 129 | } |
||||||
| 130 | // if set for each link => overwrite $display |
||||||
| 131 | if (isset($GLOBALS['xoopsModuleConfig']['display_text_each_link'][$image])) { |
||||||
| 132 | $display = empty($GLOBALS['xoopsModuleConfig']['display_text_each_link'][$image]); |
||||||
| 133 | } |
||||||
| 134 | } |
||||||
| 135 | // END hacked by irmtfan |
||||||
| 136 | if ($display === false) { |
||||||
| 137 | return $iconHandler->assignImage($image, $alt, $extra); |
||||||
| 138 | } |
||||||
| 139 | |||||||
| 140 | return $iconHandler->getImage($image, $alt, $extra); |
||||||
| 141 | } |
||||||
| 142 | |||||||
| 143 | /** |
||||||
| 144 | * @return IconHandler |
||||||
| 145 | */ |
||||||
| 146 | function newbbGetIconHandler(): IconHandler |
||||||
| 147 | { |
||||||
| 148 | global $xoTheme; |
||||||
| 149 | static $iconHandler; |
||||||
| 150 | |||||||
| 151 | if (null !== $iconHandler) { |
||||||
| 152 | return $iconHandler; |
||||||
| 153 | } |
||||||
| 154 | |||||||
| 155 | // if (!class_exists('IconHandler')) { |
||||||
| 156 | // require_once \dirname(__DIR__) . '/class/icon.php'; |
||||||
| 157 | // } |
||||||
| 158 | |||||||
| 159 | |||||||
| 160 | $helper = Helper::getInstance(); |
||||||
| 161 | $iconHandler = $helper->getHandler('Icon'); |
||||||
| 162 | // $iconHandler = new IconHandler(); |
||||||
| 163 | $iconHandler->template = $xoTheme->template; |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 164 | $iconHandler->init($GLOBALS['xoopsConfig']['language']); |
||||||
|
0 ignored issues
–
show
The method
init() 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...
|
|||||||
| 165 | |||||||
| 166 | return $iconHandler; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 167 | } |
||||||
| 168 | } |
||||||
| 169 |