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 | // ------------------------------------------------------------------------ // |
||
4 | // XOOPS - PHP Content Management System // |
||
5 | // Copyright (c) 2000-2020 XOOPS.org // |
||
6 | // <https://xoops.org> // |
||
7 | // ------------------------------------------------------------------------ // |
||
8 | // This program is free software; you can redistribute it and/or modify // |
||
9 | // it under the terms of the GNU General Public License as published by // |
||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||
11 | // (at your option) any later version. // |
||
12 | // // |
||
13 | // You may not change or alter any portion of this comment or credits // |
||
14 | // of supporting developers from this source code or any supporting // |
||
15 | // source code which is considered copyrighted (c) material of the // |
||
16 | // original comment or credit authors. // |
||
17 | // // |
||
18 | // This program is distributed in the hope that it will be useful, // |
||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
21 | // GNU General Public License for more details. // |
||
22 | // // |
||
23 | // You should have received a copy of the GNU General Public License // |
||
24 | // along with this program; if not, write to the Free Software // |
||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
26 | // ------------------------------------------------------------------------ // |
||
27 | // Author: phppp (D.J., [email protected]) // |
||
28 | // URL: https://xoops.org // |
||
29 | // Project: Article Project // |
||
30 | // ------------------------------------------------------------------------ // |
||
31 | |||
32 | |||
33 | use XoopsModules\Newbb; |
||
34 | |||
35 | if (defined('XOOPS_MODULE_NEWBB_FUCTIONS')) { |
||
36 | exit(); |
||
37 | } |
||
38 | define('XOOPS_MODULE_NEWBB_FUCTIONS', 1); |
||
39 | |||
40 | require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); |
||
41 | |||
42 | /** |
||
43 | * @param XoopsModule $module |
||
44 | * @param null $oldversion |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
45 | * @return bool |
||
46 | */ |
||
47 | function xoops_module_update_newbb(\XoopsModule $module, $oldversion = null) |
||
48 | { |
||
49 | $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
||
50 | $cacheHelper->delete('config'); |
||
51 | |||
52 | $newbbConfig = newbbLoadConfig(); |
||
53 | |||
54 | // remove old html template files |
||
55 | // create an array with all folders, and then run this once |
||
56 | |||
57 | $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/'); |
||
58 | $template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
||
59 | foreach ($template_list as $k => $v) { |
||
60 | $fileinfo = new \SplFileInfo($templateDirectory . $v); |
||
61 | if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
||
62 | @unlink($templateDirectory . $v); |
||
63 | } |
||
64 | } |
||
65 | $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/blocks'); |
||
66 | $template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
||
67 | foreach ($template_list as $k => $v) { |
||
68 | $fileinfo = new \SplFileInfo($templateDirectory . $v); |
||
69 | if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
||
70 | @unlink($templateDirectory . $v); |
||
71 | } |
||
72 | } |
||
73 | // Load class XoopsFile |
||
74 | xoops_load('xoopsfile'); |
||
75 | //remove /images directory |
||
76 | $imagesDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/images/'); |
||
77 | $folderHandler = \XoopsFile::getHandler('folder', $imagesDirectory); |
||
78 | $folderHandler->delete($imagesDirectory); |
||
79 | |||
80 | //remove old changelogs |
||
81 | array_map('\unlink', glob(dirname(__DIR__) . '/docs/changelog-rev*.txt', GLOB_NOSORT)); |
||
82 | |||
83 | if (!empty($newbbConfig['syncOnUpdate'])) { |
||
84 | require_once dirname(__DIR__) . '/include/functions.recon.php'; |
||
85 | newbbSynchronization(); |
||
86 | } |
||
87 | |||
88 | return true; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * @param XoopsModule $module |
||
93 | * @return bool |
||
94 | */ |
||
95 | function xoops_module_pre_update_newbb(\XoopsModule $module) |
||
96 | { |
||
97 | // XoopsLoad::load('migrate', 'newbb'); |
||
98 | /** @var \XoopsModules\Newbb\Common\Configurator $configurator */ |
||
99 | $configurator = new \XoopsModules\Newbb\Common\Configurator(); |
||
100 | |||
101 | $migrator = new \XoopsModules\Newbb\Common\Migrate($configurator); |
||
102 | $migrator->synchronizeSchema(); |
||
103 | |||
104 | return true; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * @param XoopsModule $module |
||
109 | * @return bool |
||
110 | */ |
||
111 | function xoops_module_pre_install_newbb(\XoopsModule $module) |
||
112 | { |
||
113 | $mod_tables = &$module->getInfo('tables'); |
||
114 | foreach ($mod_tables as $table) { |
||
115 | $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
||
116 | } |
||
117 | |||
118 | return true; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @param XoopsModule $module |
||
123 | * @return bool |
||
124 | */ |
||
125 | function xoops_module_install_newbb(\XoopsModule $module) |
||
126 | { |
||
127 | /* Create a test category */ |
||
128 | /** @var Newbb\CategoryHandler $categoryHandler */ |
||
129 | $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); |
||
130 | $category = $categoryHandler->create(); |
||
131 | $category->setVar('cat_title', _MI_NEWBB_INSTALL_CAT_TITLE, true); |
||
132 | $category->setVar('cat_image', '', true); |
||
133 | $category->setVar('cat_description', _MI_NEWBB_INSTALL_CAT_DESC, true); |
||
134 | $category->setVar('cat_url', 'https://xoops.org XOOPS Project', true); |
||
135 | if (!$cat_id = $categoryHandler->insert($category)) { |
||
136 | return true; |
||
137 | } |
||
138 | |||
139 | /* Create a forum for test */ |
||
140 | /** @var Newbb\ForumHandler $forumHandler */ |
||
141 | $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); |
||
142 | $forum = $forumHandler->create(); |
||
143 | $forum->setVar('forum_name', _MI_NEWBB_INSTALL_FORUM_NAME, true); |
||
144 | $forum->setVar('forum_desc', _MI_NEWBB_INSTALL_FORUM_DESC, true); |
||
145 | $forum->setVar('forum_moderator', []); |
||
146 | $forum->setVar('parent_forum', 0); |
||
147 | $forum->setVar('cat_id', $cat_id); |
||
148 | $forum->setVar('attach_maxkb', 100); |
||
149 | $forum->setVar('attach_ext', 'zip|jpg|gif|png'); |
||
150 | $forum->setVar('hot_threshold', 20); |
||
151 | $forum_id = $forumHandler->insert($forum); |
||
152 | |||
153 | /* Set corresponding permissions for the category and the forum */ |
||
154 | $module_id = $module->getVar('mid'); |
||
155 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
156 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
157 | $groups_view = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS]; |
||
158 | $groups_post = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS]; |
||
159 | // irmtfan bug fix: html and signature permissions, add: pdf and print permissions |
||
160 | $post_items = [ |
||
161 | 'post', |
||
162 | 'reply', |
||
163 | 'edit', |
||
164 | 'delete', |
||
165 | 'addpoll', |
||
166 | 'vote', |
||
167 | 'attach', |
||
168 | 'noapprove', |
||
169 | 'type', |
||
170 | 'html', |
||
171 | 'signature', |
||
172 | 'pdf', |
||
173 | 'print', |
||
174 | ]; |
||
175 | foreach ($groups_view as $group_id) { |
||
176 | $grouppermHandler->addRight('category_access', $cat_id, $group_id, $module_id); |
||
177 | $grouppermHandler->addRight('forum_access', $forum_id, $group_id, $module_id); |
||
178 | $grouppermHandler->addRight('forum_view', $forum_id, $group_id, $module_id); |
||
179 | } |
||
180 | foreach ($groups_post as $group_id) { |
||
181 | foreach ($post_items as $item) { |
||
182 | $grouppermHandler->addRight('forum_' . $item, $forum_id, $group_id, $module_id); |
||
183 | } |
||
184 | } |
||
185 | |||
186 | /* Create a test post */ |
||
187 | require_once __DIR__ . '/functions.user.php'; |
||
188 | /** @var Newbb\PostHandler $postHandler */ |
||
189 | $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); |
||
190 | /** @var $forumpost */ |
||
191 | $forumpost = $postHandler->create(); |
||
192 | $forumpost->setVar('poster_ip', \Xmf\IPAddress::fromRequest()->asReadable()); |
||
193 | $forumpost->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); |
||
194 | $forumpost->setVar('approved', 1); |
||
195 | $forumpost->setVar('forum_id', $forum_id); |
||
196 | $forumpost->setVar('subject', _MI_NEWBB_INSTALL_POST_SUBJECT, true); |
||
197 | $forumpost->setVar('dohtml', 1); |
||
198 | $forumpost->setVar('dosmiley', 1); |
||
199 | $forumpost->setVar('doxcode', 1); |
||
200 | $forumpost->setVar('dobr', 1); |
||
201 | $forumpost->setVar('icon', '', true); |
||
202 | $forumpost->setVar('attachsig', 1); |
||
203 | $forumpost->setVar('post_time', time()); |
||
204 | $forumpost->setVar('post_text', _MI_NEWBB_INSTALL_POST_TEXT, true); |
||
205 | $postid = $postHandler->insert($forumpost); |
||
206 | |||
207 | return true; |
||
208 | } |
||
209 |