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 | 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 | * oledrion |
||
| 14 | * |
||
| 15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 16 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2.0 or later} |
||
| 17 | * @author phppp (D.J., [email protected]) |
||
| 18 | */ |
||
| 19 | |||
| 20 | use Xmf\Request; |
||
| 21 | use XoopsModules\Xlanguage\Utility as XlanguageUtility; |
||
| 22 | use XoopsModules\Newbb\{ |
||
| 23 | Forum, |
||
| 24 | Helper, |
||
| 25 | Post, |
||
| 26 | PostHandler, |
||
| 27 | TopicHandler, |
||
| 28 | ForumHandler |
||
| 29 | }; |
||
| 30 | |||
| 31 | $moduleDirName = basename(__DIR__); |
||
| 32 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
||
| 33 | |||
| 34 | use tecnickcom\tcpdf; |
||
|
0 ignored issues
–
show
|
|||
| 35 | |||
| 36 | // a complete rewrite by irmtfan to enhance: 1- RTL 2- Multilanguage (EMLH and Xlanguage) |
||
| 37 | error_reporting(0); |
||
| 38 | require_once __DIR__ . '/header.php'; |
||
| 39 | |||
| 40 | $helper = Helper::getInstance(); |
||
| 41 | $attach_id = Request::getString('attachid', '', 'GET'); |
||
| 42 | $forum = Request::getInt('forum', 0, 'GET'); |
||
| 43 | $topic_id = Request::getInt('topic_id', 0, 'GET'); |
||
| 44 | $post_id = Request::getInt('post_id', 0, 'GET'); |
||
| 45 | |||
| 46 | if (is_file(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php')) { |
||
| 47 | require_once XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php'; |
||
| 48 | } else { |
||
| 49 | redirect_header($helper->url('viewtopic.php?topic_id=' . $topic_id), 3, \constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_NO_PDF')); |
||
| 50 | } |
||
| 51 | |||
| 52 | if (empty($post_id)) { |
||
| 53 | exit(_MD_NEWBB_ERRORTOPIC); |
||
| 54 | } |
||
| 55 | ///** @var PostHandler $postHandler */ |
||
| 56 | //$postHandler = Helper::getInstance()->getHandler('Post'); |
||
| 57 | /** @var Post $post */ |
||
| 58 | $post = $postHandler->get($post_id); |
||
| 59 | if (!$approved = $post->getVar('approved')) { |
||
| 60 | exit(_MD_NEWBB_NORIGHTTOVIEW); |
||
| 61 | } |
||
| 62 | $post_data = $postHandler->getPostForPDF($post); |
||
| 63 | //$post_edit = $post->displayPostEdit(); //reserve for future versions to display edit records |
||
| 64 | ///** @var TopicHandler $topicHandler */ |
||
| 65 | //$topicHandler = Helper::getInstance()->getHandler('Topic'); |
||
| 66 | $forumtopic = $topicHandler->getByPost($post_id); |
||
| 67 | $topic_id = $forumtopic->getVar('topic_id'); |
||
| 68 | if (!$approved = $forumtopic->getVar('approved')) { |
||
| 69 | exit(_MD_NEWBB_NORIGHTTOVIEW); |
||
| 70 | } |
||
| 71 | ///** @var ForumHandler $forumHandler */ |
||
| 72 | //$forumHandler = Helper::getInstance()->getHandler('Forum'); |
||
| 73 | $forum = $forum ?: $forumtopic->getVar('forum_id'); |
||
| 74 | /** @var Forum $viewtopic_forum */ |
||
| 75 | $viewtopic_forum = $forumHandler->get($forum); |
||
| 76 | $parent_forums = []; |
||
| 77 | $parent_forums = $forumHandler->getParents($viewtopic_forum); |
||
| 78 | $pf_title = ''; |
||
| 79 | if ($parent_forums) { |
||
| 80 | foreach ($parent_forums as $p_f) { |
||
| 81 | $pf_title .= $p_f['forum_name'] . ' - '; |
||
| 82 | } |
||
| 83 | } |
||
| 84 | if (!$forumHandler->getPermission($viewtopic_forum)) { |
||
| 85 | exit(_MD_NEWBB_NORIGHTTOACCESS); |
||
| 86 | } |
||
| 87 | if (!$topicHandler->getPermission($viewtopic_forum, $forumtopic->getVar('topic_status'), 'view')) { |
||
| 88 | exit(_MD_NEWBB_NORIGHTTOVIEW); |
||
| 89 | } |
||
| 90 | // irmtfan add pdf permission |
||
| 91 | if (!$topicHandler->getPermission($viewtopic_forum, $forumtopic->getVar('topic_status'), 'pdf')) { |
||
| 92 | exit(_MD_NEWBB_NORIGHTTOPDF); |
||
| 93 | } |
||
| 94 | //$categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); |
||
| 95 | $cat = $viewtopic_forum->getVar('cat_id'); |
||
| 96 | $viewtopic_cat = $categoryHandler->get($cat); |
||
| 97 | $GLOBALS['xoopsOption']['pdf_cache'] = 0; |
||
| 98 | $pdf_data['author'] = $myts->undoHtmlSpecialChars((string)$post_data['author']); |
||
| 99 | $pdf_data['title'] = $myts->undoHtmlSpecialChars((string)$post_data['subject']); |
||
| 100 | $content = ''; |
||
| 101 | $content .= '<b>' . $pdf_data['title'] . '</b><br><br>'; |
||
| 102 | $content .= _MD_NEWBB_AUTHORC . ' ' . $pdf_data['author'] . '<br>'; |
||
| 103 | $content .= _MD_NEWBB_POSTEDON . ' ' . formatTimestamp($post_data['date']) . '<br><br><br>'; |
||
| 104 | $content .= $myts->undoHtmlSpecialChars((string)$post_data['text']) . '<br>'; |
||
| 105 | //$content .= $post_edit . '<br>'; //reserve for future versions to display edit records |
||
| 106 | $pdf_data['content'] = str_replace('[pagebreak]', '<br>', $content); |
||
| 107 | $pdf_data['topic_title'] = $forumtopic->getVar('topic_title'); |
||
| 108 | $pdf_data['forum_title'] = $pf_title . $viewtopic_forum->getVar('forum_name'); |
||
| 109 | $pdf_data['cat_title'] = $viewtopic_cat->getVar('cat_title'); |
||
| 110 | $pdf_data['subject'] = _MD_NEWBB_PDF_SUBJECT . ': ' . $pdf_data['topic_title']; |
||
| 111 | $pdf_data['keywords'] = XOOPS_URL . ', ' . 'XOOPS Project, ' . $pdf_data['topic_title']; |
||
| 112 | $pdf_data['HeadFirstLine'] = $GLOBALS['xoopsConfig']['sitename'] . ' - ' . $GLOBALS['xoopsConfig']['slogan']; |
||
| 113 | $pdf_data['HeadSecondLine'] = _MD_NEWBB_FORUMHOME . ' - ' . $pdf_data['cat_title'] . ' - ' . $pdf_data['forum_title'] . ' - ' . $pdf_data['topic_title']; |
||
| 114 | // START irmtfan to implement EMLH by GIJ |
||
| 115 | if (function_exists('easiestml')) { |
||
| 116 | $pdf_data = easiestml($pdf_data); |
||
| 117 | // END irmtfan to implement EMLH by GIJ |
||
| 118 | // START irmtfan to implement Xlanguage by phppp(DJ) |
||
| 119 | } elseif (class_exists('XlanguageUtility')) { |
||
| 120 | $pdf_data = XlanguageUtility::cleanMultiLang($pdf_data); |
||
| 121 | } |
||
| 122 | // END irmtfan to implement Xlanguage by phppp(DJ) |
||
| 123 | |||
| 124 | $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, _CHARSET, false); |
||
|
0 ignored issues
–
show
|
|||
| 125 | // load $localLanguageOptions array with language specific definitions and apply |
||
| 126 | //if (is_file(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/config/lang/' . $GLOBALS['xoopsConfig']['language'] . '.php')) { |
||
| 127 | //require_once XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/config/lang/' . $GLOBALS['xoopsConfig']['language'] . '.php'; |
||
| 128 | //} else { |
||
| 129 | //require_once XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/config/lang/english.php'; |
||
| 130 | //} |
||
| 131 | // set some language dependent data: |
||
| 132 | $lg = []; |
||
| 133 | $lg['a_meta_charset'] = _CHARSET; |
||
| 134 | //$lg['a_meta_dir'] = _MD_NEWBB_PDF_META_DIR; |
||
| 135 | $lg['a_meta_language'] = _LANGCODE; |
||
| 136 | $lg['w_page'] = _MD_NEWBB_PDF_PAGE2; |
||
| 137 | |||
| 138 | // set some language-dependent strings (optional) |
||
| 139 | $pdf->setLanguageArray($lg); |
||
| 140 | //$pdf->setLanguageArray($localLanguageOptions); |
||
| 141 | // set some language-dependent strings (optional) |
||
| 142 | $pdf->setLanguageArray($lg); |
||
| 143 | //$pdf->setLanguageArray($localLanguageOptions); |
||
| 144 | // START irmtfan hack to add RTL-LTR local |
||
| 145 | // until _RTL added to core 2.6.0 |
||
| 146 | if (!defined('_RTL')) { |
||
| 147 | define('_RTL', false); |
||
| 148 | } |
||
| 149 | $pdf->setRTL(_RTL); |
||
| 150 | // END irmtfan hack to add RTL-LTR local |
||
| 151 | |||
| 152 | // set document information |
||
| 153 | $pdf->SetCreator(PDF_CREATOR); |
||
|
0 ignored issues
–
show
|
|||
| 154 | $pdf->SetAuthor(PDF_AUTHOR); |
||
|
0 ignored issues
–
show
|
|||
| 155 | $pdf->SetTitle($pdf_data['forum_title'] . ' - ' . $pdf_data['subject']); |
||
| 156 | $pdf->SetSubject($pdf_data['subject']); |
||
| 157 | $pdf->SetKeywords($pdf_data['keywords']); |
||
| 158 | |||
| 159 | //$pdf->SetHeaderData('', '5', $pdf_data['HeadFirstLine'], $pdf_data['HeadSecondLine']); |
||
| 160 | $pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $pdf_data['HeadFirstLine'], $pdf_data['HeadSecondLine'], [0, 64, 255], [0, 64, 128]); |
||
|
0 ignored issues
–
show
|
|||
| 161 | |||
| 162 | //set margins |
||
| 163 | $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); |
||
|
0 ignored issues
–
show
|
|||
| 164 | $pdf->setHeaderMargin(PDF_MARGIN_HEADER); |
||
|
0 ignored issues
–
show
|
|||
| 165 | $pdf->setFooterMargin(PDF_MARGIN_FOOTER); |
||
|
0 ignored issues
–
show
|
|||
| 166 | |||
| 167 | //set auto page breaks |
||
| 168 | $pdf->SetAutoPageBreak(true, 25); |
||
| 169 | $pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]); |
||
|
0 ignored issues
–
show
|
|||
| 170 | $pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]); |
||
|
0 ignored issues
–
show
|
|||
| 171 | $pdf->setFooterData($tc = [0, 64, 0], $lc = [0, 64, 128]); |
||
| 172 | $pdf->Open(); |
||
| 173 | $pdf->AddPage(); |
||
| 174 | |||
| 175 | //$pdf->SetFont(PDF_FONT_NAME_MAIN, PDF_FONT_STYLE_MAIN, PDF_FONT_SIZE_MAIN); |
||
| 176 | $pdf->SetFont('dejavusans', '', 12); |
||
| 177 | $pdf->writeHTML($pdf_data['content'], true, 0); |
||
| 178 | $pdf->Output($pdf_data['topic_title'] . '_' . $post_id . '.pdf', 'I'); |
||
| 179 |
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