Passed
Pull Request — master (#18)
by Michael
02:44
created

Post   F

Complexity

Total Complexity 121

Size/Duplication

Total Lines 645
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 398
c 1
b 0
f 0
dl 0
loc 645
rs 2
wmc 121

14 Methods

Rating   Name   Duplication   Size   Complexity  
B setPostEdit() 0 32 10
A isTopic() 0 3 1
A getAttachment() 0 13 3
C getPostBody() 0 43 15
B displayPostEdit() 0 38 11
F showPost() 0 242 42
A incrementDownload() 0 8 2
A setAttachment() 0 20 5
B deleteAttachment() 0 30 9
B displayAttachment() 0 56 11
A saveAttachment() 0 14 4
A checkIdentity() 0 19 5
A checkTimelimit() 0 8 2
A __construct() 0 25 1

How to fix   Complexity   

Complex Class

Complex classes like Post often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Post, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace XoopsModules\Newbb;
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
 * @copyright    {@link https://xoops.org/ XOOPS Project}
17
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
18
 * @package
19
 * @since
20
 * @author       XOOPS Development Team, phppp (D.J., [email protected])
21
 */
22
23
use Xmf\Request;
24
use XoopsModules\Newbb;
25
26
27
28
\defined('NEWBB_FUNCTIONS_INI') || require XOOPS_ROOT_PATH . '/modules/newbb/include/functions.ini.php';
29
newbb_load_object();
0 ignored issues
show
Bug introduced by
The function newbb_load_object was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
/** @scrutinizer ignore-call */ 
30
newbb_load_object();
Loading history...
30
31
/**
32
 * Class Post
33
 */
34
class Post extends \XoopsObject
35
{
36
    //class Post extends \XoopsObject {
37
    public $attachment_array = [];
38
39
    /**
40
     * Post constructor.
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct('bb_posts');
0 ignored issues
show
Unused Code introduced by
The call to XoopsObject::__construct() has too many arguments starting with 'bb_posts'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
        parent::/** @scrutinizer ignore-call */ 
45
                __construct('bb_posts');

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
45
        $this->initVar('post_id', \XOBJ_DTYPE_INT);
46
        $this->initVar('topic_id', \XOBJ_DTYPE_INT, 0, true);
47
        $this->initVar('forum_id', \XOBJ_DTYPE_INT, 0, true);
48
        $this->initVar('post_time', \XOBJ_DTYPE_INT, 0, true);
49
        $this->initVar('poster_ip', \XOBJ_DTYPE_INT, 0);
50
        $this->initVar('poster_name', \XOBJ_DTYPE_TXTBOX, '');
51
        $this->initVar('subject', \XOBJ_DTYPE_TXTBOX, '', true);
52
        $this->initVar('pid', \XOBJ_DTYPE_INT, 0);
53
        $this->initVar('dohtml', \XOBJ_DTYPE_INT, 0);
54
        $this->initVar('dosmiley', \XOBJ_DTYPE_INT, 1);
55
        $this->initVar('doxcode', \XOBJ_DTYPE_INT, 1);
56
        $this->initVar('doimage', \XOBJ_DTYPE_INT, 1);
57
        $this->initVar('dobr', \XOBJ_DTYPE_INT, 1);
58
        $this->initVar('uid', \XOBJ_DTYPE_INT, 1);
59
        $this->initVar('icon', \XOBJ_DTYPE_TXTBOX, '');
60
        $this->initVar('attachsig', \XOBJ_DTYPE_INT, 0);
61
        $this->initVar('approved', \XOBJ_DTYPE_INT, 1);
62
        $this->initVar('post_karma', \XOBJ_DTYPE_INT, 0);
63
        $this->initVar('require_reply', \XOBJ_DTYPE_INT, 0);
64
        $this->initVar('attachment', \XOBJ_DTYPE_TXTAREA, '');
65
        $this->initVar('post_text', \XOBJ_DTYPE_TXTAREA, '');
66
        $this->initVar('post_edit', \XOBJ_DTYPE_TXTAREA, '');
67
    }
68
69
    // ////////////////////////////////////////////////////////////////////////////////////
70
    // attachment functions    TODO: there should be a file/attachment management class
71
72
    /**
73
     * @return array|mixed|null
74
     */
75
    public function getAttachment()
76
    {
77
        if (\count($this->attachment_array)) {
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachmentArray?
Loading history...
78
            return $this->attachment_array;
79
        }
80
        $attachment = $this->getVar('attachment');
81
        if (empty($attachment)) {
82
            $this->attachment_array = null;
83
        } else {
84
            $this->attachment_array = @\unserialize(\base64_decode($attachment, true));
0 ignored issues
show
Bug introduced by
It seems like $attachment can also be of type array and array; however, parameter $data of base64_decode() 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 ignore-type  annotation

84
            $this->attachment_array = @\unserialize(\base64_decode(/** @scrutinizer ignore-type */ $attachment, true));
Loading history...
85
        }
86
87
        return $this->attachment_array;
88
    }
89
90
    /**
91
     * @param $attach_key
92
     * @return bool
93
     */
94
    public function incrementDownload($attach_key)
95
    {
96
        if (!$attach_key) {
97
            return false;
98
        }
99
        $this->attachment_array[(string)$attach_key]['num_download']++;
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachmentArray?
Loading history...
100
101
        return $this->attachment_array[(string)$attach_key]['num_download'];
102
    }
103
104
    /**
105
     * @return bool
106
     */
107
    public function saveAttachment()
108
    {
109
        $attachment_save = '';
110
        if ($this->attachment_array && \is_array($this->attachment_array)) {
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachmentArray?
Loading history...
111
            $attachment_save = \base64_encode(\serialize($this->attachment_array));
112
        }
113
        $this->setVar('attachment', $attachment_save);
114
        $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' SET attachment=' . $GLOBALS['xoopsDB']->quoteString($attachment_save) . ' WHERE post_id = ' . $this->getVar('post_id');
115
        if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
116
            //xoops_error($GLOBALS["xoopsDB"]->error());
117
            return false;
118
        }
119
120
        return true;
121
    }
122
123
    /**
124
     * @param null $attach_array
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $attach_array is correct as it would always require null to be passed?
Loading history...
125
     * @return bool
126
     */
127
    public function deleteAttachment($attach_array = null)
128
    {
129
        $attach_old = $this->getAttachment();
130
        if (!\is_array($attach_old) || \count($attach_old) < 1) {
131
            return true;
132
        }
133
        $this->attachment_array = [];
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachmentArray?
Loading history...
134
135
        if (null === $attach_array) {
0 ignored issues
show
introduced by
The condition null === $attach_array is always true.
Loading history...
136
            $attach_array = \array_keys($attach_old);
137
        } // to delete all!
138
        if (!\is_array($attach_array)) {
0 ignored issues
show
introduced by
The condition is_array($attach_array) is always true.
Loading history...
139
            $attach_array = [$attach_array];
140
        }
141
142
        foreach ($attach_old as $key => $attach) {
143
            if (\in_array($key, $attach_array)) {
144
                @\unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for unlink(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

144
                /** @scrutinizer ignore-unhandled */ @\unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
145
                @\unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/thumbs/' . $attach['name_saved']); // delete thumbnails
146
                continue;
147
            }
148
            $this->attachment_array[$key] = $attach;
149
        }
150
        $attachment_save = '';
151
        if ($this->attachment_array && \is_array($this->attachment_array)) {
152
            $attachment_save = \base64_encode(\serialize($this->attachment_array));
153
        }
154
        $this->setVar('attachment', $attachment_save);
155
156
        return true;
157
    }
158
159
    /**
160
     * @param string $name_saved
161
     * @param string $name_display
162
     * @param string $mimetype
163
     * @param int    $num_download
164
     * @return bool
165
     */
166
    public function setAttachment($name_saved = '', $name_display = '', $mimetype = '', $num_download = 0)
167
    {
168
        static $counter = 0;
169
        $this->attachment_array = $this->getAttachment();
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachmentArray?
Loading history...
170
        if ($name_saved) {
171
            $key                          = (string)(\time() + $counter++);
172
            $this->attachment_array[$key] = [
173
                'name_saved'   => $name_saved,
174
                'name_display' => isset($name_display) ? $name_display : $name_saved,
175
                'mimetype'     => $mimetype,
176
                'num_download' => isset($num_download) ? (int)$num_download : 0,
177
            ];
178
        }
179
        $attachment_save = null;
180
        if (\is_array($this->attachment_array)) {
181
            $attachment_save = \base64_encode(\serialize($this->attachment_array));
182
        }
183
        $this->setVar('attachment', $attachment_save);
184
185
        return true;
186
    }
187
188
    /**
189
     * TODO: refactor
190
     * @param bool $asSource
191
     * @return string
192
     */
193
    public function displayAttachment($asSource = false)
0 ignored issues
show
Unused Code introduced by
The parameter $asSource is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

193
    public function displayAttachment(/** @scrutinizer ignore-unused */ $asSource = false)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
194
    {
195
        $post_attachment = '';
196
        $attachments     = $this->getAttachment();
197
        if ($attachments && \is_array($attachments)) {
198
            $iconHandler = newbb_getIconHandler();
0 ignored issues
show
Bug introduced by
The function newbb_getIconHandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

198
            $iconHandler = /** @scrutinizer ignore-call */ newbb_getIconHandler();
Loading history...
199
            $mime_path   = $iconHandler->getPath('mime');
200
            require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/include/functions.image.php');
201
            $image_extensions = ['jpg', 'jpeg', 'gif', 'png', 'bmp']; // need improve !!!
202
            $post_attachment  .= '<br><strong>' . _MD_ATTACHMENT . '</strong>:';
203
            $post_attachment  .= "<div style='margin: 1em 0; border-top: 1px solid;'></div>\n";
204
            //            $post_attachment .= '<br><hr style="height: 1px;" noshade="noshade"><br>';
205
            foreach ($attachments as $key => $att) {
206
                $file_extension = \ltrim(mb_strrchr($att['name_saved'], '.'), '.');
207
                $filetype       = $file_extension;
208
                if (\file_exists($GLOBALS['xoops']->path("{$mime_path}/{$filetype}.gif"))) {
209
                    $icon_filetype = $GLOBALS['xoops']->url("{$mime_path}/{$filetype}.gif");
210
                } else {
211
                    $icon_filetype = $GLOBALS['xoops']->url("{$mime_path}/unknown.gif");
212
                }
213
                $file_size = @\filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved']));
214
                $file_size = \number_format($file_size / 1024, 2) . ' KB';
215
                if ($GLOBALS['xoopsModuleConfig']['media_allowed']
216
                    && \in_array(mb_strtolower($file_extension), $image_extensions)) {
217
                    $post_attachment .= '<br><img src="' . $icon_filetype . '" alt="' . $filetype . '"><strong>&nbsp; ' . $att['name_display'] . '</strong> <small>(' . $file_size . ')</small>';
218
                    $post_attachment .= '<br>' . newbb_attachmentImage($att['name_saved']);
0 ignored issues
show
Bug introduced by
The function newbb_attachmentImage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

218
                    $post_attachment .= '<br>' . /** @scrutinizer ignore-call */ newbb_attachmentImage($att['name_saved']);
Loading history...
219
                    $isDisplayed     = true;
0 ignored issues
show
Unused Code introduced by
The assignment to $isDisplayed is dead and can be removed.
Loading history...
220
                } else {
221
                    if (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) {
222
                        $post_attachment .= "<a href='"
223
                                            . $GLOBALS['xoops']->url('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . "/dl_attachment.php?attachid={$key}&amp;post_id=" . $this->getVar('post_id'))
224
                                            . "'> <img src='{$icon_filetype}' alt='{$filetype}'> {$att['name_display']}</a> "
225
                                            . _MD_FILESIZE
226
                                            . ": {$file_size}; "
227
                                            . _MD_HITS
228
                                            . ": {$att['num_download']}";
229
                    } elseif (($GLOBALS['xoopsUser'] instanceof \XoopsUser) && $GLOBALS['xoopsUser']->uid() > 0
230
                              && $GLOBALS['xoopsUser']->isActive()) {
231
                        $post_attachment .= "<a href='"
232
                                            . $GLOBALS['xoops']->url('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . "/dl_attachment.php?attachid={$key}&amp;post_id=" . $this->getVar('post_id'))
233
                                            . "'> <img src='"
234
                                            . $icon_filetype
235
                                            . "' alt='{$filetype}'> {$att['name_display']}</a> "
236
                                            . _MD_FILESIZE
237
                                            . ": {$file_size}; "
238
                                            . _MD_HITS
239
                                            . ": {$att['num_download']}";
240
                    } else {
241
                        $post_attachment .= _MD_NEWBB_SEENOTGUEST;
242
                    }
243
                }
244
                $post_attachment .= '<br>';
245
            }
246
        }
247
248
        return $post_attachment;
249
    }
250
251
    // attachment functions
252
    // ////////////////////////////////////////////////////////////////////////////////////
253
254
    /**
255
     * @param string $poster_name
256
     * @param string $post_editmsg
257
     * @return bool
258
     */
259
    public function setPostEdit($poster_name = '', $post_editmsg = '')
0 ignored issues
show
Unused Code introduced by
The parameter $poster_name is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

259
    public function setPostEdit(/** @scrutinizer ignore-unused */ $poster_name = '', $post_editmsg = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
260
    {
261
        if ($this->getVar('approved') < 1
262
            || empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])
263
            || (\time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60) {
264
            return true;
265
        }
266
        if (($GLOBALS['xoopsUser'] instanceof \XoopsUser) && $GLOBALS['xoopsUser']->isActive()) {
267
            if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $GLOBALS['xoopsUser']->getVar('name')) {
268
                $edit_user = $GLOBALS['xoopsUser']->getVar('name');
269
            } else {
270
                $edit_user = $GLOBALS['xoopsUser']->getVar('uname');
271
            }
272
        }
273
        $post_edit              = [];
274
        $post_edit['edit_user'] = $edit_user; // The proper way is to store uid instead of name. However, to save queries when displaying, the current way is ok.
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $edit_user does not seem to be defined for all execution paths leading up to this point.
Loading history...
275
        $post_edit['edit_time'] = \time();
276
        $post_edit['edit_msg']  = $post_editmsg;
277
278
        $post_edits = $this->getVar('post_edit');
279
        if (!empty($post_edits)) {
280
            $post_edits = \unserialize(\base64_decode($post_edits, true));
0 ignored issues
show
Bug introduced by
It seems like $post_edits can also be of type array and array; however, parameter $data of base64_decode() 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 ignore-type  annotation

280
            $post_edits = \unserialize(\base64_decode(/** @scrutinizer ignore-type */ $post_edits, true));
Loading history...
281
        }
282
        if (!\is_array($post_edits)) {
283
            $post_edits = [];
284
        }
285
        $post_edits[] = $post_edit;
286
        $post_edit    = \base64_encode(\serialize($post_edits));
287
        unset($post_edits);
288
        $this->setVar('post_edit', $post_edit);
289
290
        return true;
291
    }
292
293
    /**
294
     * @return bool|string
295
     */
296
    public function displayPostEdit()
297
    {
298
        global $myts;
299
300
        if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])) {
301
            return false;
302
        }
303
304
        $post_edit  = '';
305
        $post_edits = $this->getVar('post_edit');
306
        if (!empty($post_edits)) {
307
            $post_edits = \unserialize(\base64_decode($post_edits, true));
0 ignored issues
show
Bug introduced by
It seems like $post_edits can also be of type array and array; however, parameter $data of base64_decode() 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 ignore-type  annotation

307
            $post_edits = \unserialize(\base64_decode(/** @scrutinizer ignore-type */ $post_edits, true));
Loading history...
308
        }
309
        if (!isset($post_edits) || !\is_array($post_edits)) {
310
            $post_edits = [];
311
        }
312
        if ($post_edits && \is_array($post_edits)) {
313
            foreach ($post_edits as $postedit) {
314
                $edit_time = (int)$postedit['edit_time'];
315
                $edit_user = $myts->stripSlashesGPC($postedit['edit_user']);
316
                $edit_msg  = !empty($postedit['edit_msg']) ? $myts->stripSlashesGPC($postedit['edit_msg']) : '';
317
                // Start irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred)
318
                if (empty($GLOBALS['xoopsModuleConfig']['do_latestedit'])) {
319
                    $post_edit = '';
320
                }
321
                // End irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred)
322
                // START hacked by irmtfan
323
                // display/save all edit records.
324
                $post_edit .= _MD_EDITEDBY . ' ' . $edit_user . ' ' . _MD_ON . ' ' . newbb_formatTimestamp($edit_time) . '<br>';
0 ignored issues
show
Bug introduced by
The function newbb_formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

324
                $post_edit .= _MD_EDITEDBY . ' ' . $edit_user . ' ' . _MD_ON . ' ' . /** @scrutinizer ignore-call */ newbb_formatTimestamp($edit_time) . '<br>';
Loading history...
325
                // if reason is not empty
326
                if ('' !== $edit_msg) {
327
                    $post_edit .= \_MD_EDITEDMSG . ' ' . $edit_msg . '<br>';
328
                }
329
                // START hacked by irmtfan
330
            }
331
        }
332
333
        return $post_edit;
334
    }
335
336
    /**
337
     * @return array
338
     */
339
    public function &getPostBody()
340
    {
341
        global $myts;
342
        $GLOBALS['xoopsModuleConfig'] = newbb_load_config(); // irmtfan  load all newbb configs - newbb config in blocks activated in some modules like profile
0 ignored issues
show
Bug introduced by
The function newbb_load_config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

342
        $GLOBALS['xoopsModuleConfig'] = /** @scrutinizer ignore-call */ newbb_load_config(); // irmtfan  load all newbb configs - newbb config in blocks activated in some modules like profile
Loading history...
343
        //        mod_loadFunctions('user', 'newbb');
344
        //        mod_loadFunctions('render', 'newbb');
345
        require_once \dirname(__DIR__) . '/include/functions.user.php';
346
        require_once \dirname(__DIR__) . '/include/functions.render.php';
347
348
        $uid          = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
349
        $karmaHandler = Newbb\Helper::getInstance()->getHandler('Karma');
350
        $user_karma   = $karmaHandler->getUserKarma();
0 ignored issues
show
Bug introduced by
The method getUserKarma() 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 ignore-call  annotation

350
        /** @scrutinizer ignore-call */ 
351
        $user_karma   = $karmaHandler->getUserKarma();
Loading history...
351
352
        $post               = [];
353
        $post['attachment'] = false;
354
        $post_text          = &newbb_displayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr'));
0 ignored issues
show
Bug introduced by
The function newbb_displayTarea was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

354
        $post_text          = &/** @scrutinizer ignore-call */ newbb_displayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr'));
Loading history...
355
        if (newbb_isAdmin($this->getVar('forum_id')) || $this->checkIdentity()) {
0 ignored issues
show
Bug introduced by
The function newbb_isAdmin was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

355
        if (/** @scrutinizer ignore-call */ newbb_isAdmin($this->getVar('forum_id')) || $this->checkIdentity()) {
Loading history...
356
            $post['text'] = $post_text . '<br>' . $this->displayAttachment();
357
        } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
358
            $post['text'] = \sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma'));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('post_karma') can also be of type array and array; however, parameter $args of sprintf() 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 ignore-type  annotation

358
            $post['text'] = \sprintf(_MD_KARMA_REQUIREMENT, $user_karma, /** @scrutinizer ignore-type */ $this->getVar('post_karma'));
Loading history...
359
        } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply')
360
                  && (!$uid || !isset($viewtopic_users[$uid]))) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $viewtopic_users seems to never exist and therefore isset should always be false.
Loading history...
361
            $post['text'] = _MD_REPLY_REQUIREMENT;
362
        } else {
363
            $post['text'] = $post_text . '<br>' . $this->displayAttachment();
364
        }
365
        $memberHandler = \xoops_getHandler('member');
366
        $eachposter    = $memberHandler->getUser($this->getVar('uid'));
0 ignored issues
show
Bug introduced by
The method getUser() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsAvatarHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

366
        /** @scrutinizer ignore-call */ 
367
        $eachposter    = $memberHandler->getUser($this->getVar('uid'));
Loading history...
367
        if (\is_object($eachposter) && $eachposter->isActive()) {
368
            if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $eachposter->getVar('name')) {
369
                $post['author'] = $eachposter->getVar('name');
370
            } else {
371
                $post['author'] = $eachposter->getVar('uname');
372
            }
373
            unset($eachposter);
374
        } else {
375
            $post['author'] = $this->getVar('poster_name') ?: $GLOBALS['xoopsConfig']['anonymous'];
376
        }
377
378
        $post['subject'] = newbb_htmlspecialchars($this->vars['subject']['value']);
0 ignored issues
show
Bug introduced by
The function newbb_htmlspecialchars was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

378
        $post['subject'] = /** @scrutinizer ignore-call */ newbb_htmlspecialchars($this->vars['subject']['value']);
Loading history...
379
        $post['date']    = $this->getVar('post_time');
380
381
        return $post;
382
    }
383
384
    /**
385
     * @return bool
386
     */
387
    public function isTopic()
388
    {
389
        return !$this->getVar('pid');
390
    }
391
392
    /**
393
     * @param string $action_tag
394
     * @return bool
395
     */
396
    public function checkTimelimit($action_tag = 'edit_timelimit')
397
    {
398
        $newbb_config = newbb_load_config();
0 ignored issues
show
Bug introduced by
The function newbb_load_config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

398
        $newbb_config = /** @scrutinizer ignore-call */ newbb_load_config();
Loading history...
399
        if (empty($newbb_config['edit_timelimit'])) {
400
            return true;
401
        }
402
403
        return ($this->getVar('post_time') > \time() - $newbb_config[$action_tag] * 60);
404
    }
405
406
    /**
407
     * @param int $uid
408
     * @return bool
409
     */
410
    public function checkIdentity($uid = -1)
411
    {
412
        //        $uid = ($uid > -1) ? $uid : (($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0);
413
        if ($uid < 0 && $GLOBALS['xoopsUser'] instanceof \XoopsUser) {
414
            $uid = $GLOBALS['xoopsUser']->getVar('uid');
415
        } else {
416
            $uid = 0;
417
        }
418
        if ($this->getVar('uid') > 0) {
419
            $user_ok = $uid === $this->getVar('uid');
420
        } else {
421
            static $user_ip;
422
            if (!isset($user_ip)) {
423
                $user_ip = \XoopsUserUtility::getIP();
424
            }
425
            $user_ok = $user_ip === $this->getVar('poster_ip');
426
        }
427
428
        return $user_ok;
429
    }
430
431
    // TODO: cleaning up and merge with post hanldings in viewpost.php
432
433
    /**
434
     * @param $isadmin
435
     * @return array
436
     */
437
    public function showPost($isadmin)
438
    {
439
        global $myts;
440
        global $forumUrl, $forumImage;
441
        global $viewtopic_users, $viewtopic_posters, $forum_obj, $topic_obj, $online, $user_karma, $viewmode, $order, $start, $total_posts, $topic_status;
442
        static $post_NO = 0;
443
        static $name_anonymous;
444
445
        if (!isset($name_anonymous)) {
446
            $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
447
        }
448
449
        //        mod_loadFunctions('time', 'newbb');
450
        //        mod_loadFunctions('render', 'newbb');
451
        //        mod_loadFunctions('text', 'newbb'); // irmtfan add text functions
452
        require_once \dirname(__DIR__) . '/include/functions.time.php';
453
        require_once \dirname(__DIR__) . '/include/functions.render.php';
454
        require_once \dirname(__DIR__) . '/include/functions.text.php';
455
456
        $post_id  = $this->getVar('post_id');
457
        $topic_id = $this->getVar('topic_id');
458
        $forum_id = $this->getVar('forum_id');
459
460
        $query_vars              = ['status', 'order', 'start', 'mode', 'viewmode'];
461
        $query_array             = [];
462
        $query_array['topic_id'] = "topic_id={$topic_id}";
463
        foreach ($query_vars as $var) {
464
            if (!empty($_GET[$var])) {
465
                $query_array[$var] = "{$var}={$_GET[$var]}";
466
            }
467
        }
468
        $page_query = \htmlspecialchars(\implode('&', \array_values($query_array)), \ENT_QUOTES | \ENT_HTML5);
469
470
        $uid = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
471
472
        ++$post_NO;
473
        if ('desc' === mb_strtolower($order)) {
474
            $post_no = $total_posts - ($start + $post_NO) + 1;
475
        } else {
476
            $post_no = $start + $post_NO;
477
        }
478
479
        if ($isadmin || $this->checkIdentity()) {
480
            $post_text       = $this->getVar('post_text');
481
            $post_attachment = $this->displayAttachment();
482
        } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
483
            $post_text       = "<div class='karma'>" . \sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '</div>';
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('post_karma') can also be of type array and array; however, parameter $args of sprintf() 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 ignore-type  annotation

483
            $post_text       = "<div class='karma'>" . \sprintf(_MD_KARMA_REQUIREMENT, $user_karma, /** @scrutinizer ignore-type */ $this->getVar('post_karma')) . '</div>';
Loading history...
484
            $post_attachment = '';
485
        } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply')
486
                  && (!$uid
487
                      || !\in_array($uid, $viewtopic_posters))) {
488
            $post_text       = "<div class='karma'>" . _MD_REPLY_REQUIREMENT . "</div>\n";
489
            $post_attachment = '';
490
        } else {
491
            $post_text       = $this->getVar('post_text');
492
            $post_attachment = $this->displayAttachment();
493
        }
494
        // START irmtfan add highlight feature
495
        // Hightlighting searched words
496
        $post_title = $this->getVar('subject');
497
        if (!empty($_GET['keywords']) && Request::hasVar('keywords', 'GET')) {
498
            $keywords   = $myts->htmlSpecialChars(\trim(\urldecode($_GET['keywords'])));
499
            $post_text  = \newbb_highlightText($post_text, $keywords);
500
            $post_title = \newbb_highlightText($post_title, $keywords);
501
        }
502
        // END irmtfan add highlight feature
503
        if (isset($viewtopic_users[$this->getVar('uid')])) {
504
            $poster = $viewtopic_users[$this->getVar('uid')];
505
        } else {
506
            $name   = ($post_name = $this->getVar('poster_name')) ? $post_name : $name_anonymous;
507
            $poster = [
508
                'poster_uid' => 0,
509
                'name'       => $name,
510
                'link'       => $name,
511
            ];
512
        }
513
514
        $posticon = $this->getVar('icon');
515
        if ($posticon) {
516
            $post_image = "<a name='{$post_id}'><img src='" . $GLOBALS['xoops']->url("images/subject/{$posticon}") . "' alt=''></a>";
517
        } else {
518
            $post_image = "<a name='{$post_id}'><img src='" . $GLOBALS['xoops']->url('images/icons/posticon.gif') . "' alt=''></a>";
519
        }
520
521
        $thread_buttons = [];
522
        $mod_buttons    = [];
523
524
        if (($this->getVar('uid') > 0)
525
            && $isadmin
526
            && (($GLOBALS['xoopsUser'] instanceof \XoopsUser)
527
                && $GLOBALS['xoopsUser']->getVar('uid') !== $this->getVar('uid'))) {
528
            $mod_buttons['bann']['image']    = newbb_displayImage('p_bann', _MD_SUSPEND_MANAGEMENT);
0 ignored issues
show
Bug introduced by
The function newbb_displayImage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

528
            $mod_buttons['bann']['image']    = /** @scrutinizer ignore-call */ newbb_displayImage('p_bann', _MD_SUSPEND_MANAGEMENT);
Loading history...
529
            $mod_buttons['bann']['link']     = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/moderate.php?forum={$forum_id}&amp;fuid=" . $this->getVar('uid'));
530
            $mod_buttons['bann']['name']     = _MD_SUSPEND_MANAGEMENT;
531
            $thread_buttons['bann']['image'] = newbb_displayImage('p_bann', _MD_SUSPEND_MANAGEMENT);
532
            $thread_buttons['bann']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/moderate.php?forum={$forum_id}&amp;fuid=" . $this->getVar('uid'));
533
            $thread_buttons['bann']['name']  = _MD_SUSPEND_MANAGEMENT;
534
        }
535
536
        if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) {
537
            /** @var Newbb\TopicHandler $topicHandler */
538
            $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
539
            $topic_status = $topic_obj->getVar('topic_status');
540
            if ($topicHandler->getPermission($forum_id, $topic_status, 'edit')) {
541
                $edit_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit')));
542
                if ($edit_ok) {
543
                    $thread_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT);
544
                    $thread_buttons['edit']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}");
545
                    $thread_buttons['edit']['name']  = _EDIT;
546
                    $mod_buttons['edit']['image']    = newbb_displayImage('p_edit', _EDIT);
547
                    $mod_buttons['edit']['link']     = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}");
548
                    $mod_buttons['edit']['name']     = _EDIT;
549
                }
550
            }
551
552
            if ($topicHandler->getPermission($forum_id, $topic_status, 'delete')) {
553
                $delete_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit')));
554
555
                if ($delete_ok) {
556
                    $thread_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE);
557
                    $thread_buttons['delete']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/delete.php?{$page_query}");
558
                    $thread_buttons['delete']['name']  = _DELETE;
559
                    $mod_buttons['delete']['image']    = newbb_displayImage('p_delete', _DELETE);
560
                    $mod_buttons['delete']['link']     = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/delete.php?{$page_query}");
561
                    $mod_buttons['delete']['name']     = _DELETE;
562
                }
563
            }
564
            if ($topicHandler->getPermission($forum_id, $topic_status, 'reply')) {
565
                $thread_buttons['reply']['image'] = newbb_displayImage('p_reply', _MD_REPLY);
566
                $thread_buttons['reply']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/reply.php?{$page_query}");
567
                $thread_buttons['reply']['name']  = _MD_REPLY;
568
569
                $thread_buttons['quote']['image'] = newbb_displayImage('p_quote', _MD_QUOTE);
570
                $thread_buttons['quote']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/reply.php?{$page_query}&amp;quotedac=1");
571
                $thread_buttons['quote']['name']  = _MD_QUOTE;
572
            }
573
        } else {
574
            $mod_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT);
575
            $mod_buttons['edit']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}");
576
            $mod_buttons['edit']['name']  = _EDIT;
577
578
            $mod_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE);
579
            $mod_buttons['delete']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/delete.php?{$page_query}");
580
            $mod_buttons['delete']['name']  = _DELETE;
581
582
            $thread_buttons['reply']['image'] = newbb_displayImage('p_reply', _MD_REPLY);
583
            $thread_buttons['reply']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/reply.php?{$page_query}");
584
            $thread_buttons['reply']['name']  = _MD_REPLY;
585
        }
586
587
        if (!$isadmin && $GLOBALS['xoopsModuleConfig']['reportmod_enabled']) {
588
            $thread_buttons['report']['image'] = newbb_displayImage('p_report', _MD_REPORT);
589
            $thread_buttons['report']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/report.php?{$page_query}");
590
            $thread_buttons['report']['name']  = _MD_REPORT;
591
        }
592
593
        $thread_action = [];
594
        // irmtfan add pdf permission
595
        if ($topicHandler->getPermission($forum_id, $topic_status, 'pdf')
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $topicHandler does not seem to be defined for all execution paths leading up to this point.
Loading history...
596
            && \file_exists($GLOBALS['xoops']->path('Frameworks/tcpdf/tcpdf.php'))) {
597
            $thread_action['pdf']['image']  = newbb_displayImage('pdf', _MD_PDF);
598
            $thread_action['pdf']['link']   = $GLOBALS['xoops']->url('modules/newbb/makepdf.php?type=post&amp;pageid=0');
599
            $thread_action['pdf']['name']   = _MD_PDF;
600
            $thread_action['pdf']['target'] = '_blank';
601
        }
602
        // irmtfan add print permission
603
        if ($topicHandler->getPermission($forum_id, $topic_status, 'print')) {
604
            $thread_action['print']['image']  = newbb_displayImage('printer', _MD_PRINT);
605
            $thread_action['print']['link']   = $GLOBALS['xoops']->url("modules/newbb/print.php?form=2&amp;forum={$forum_id}&amp;topic_id={$topic_id}");
606
            $thread_action['print']['name']   = _MD_PRINT;
607
            $thread_action['print']['target'] = '_blank';
608
        }
609
610
        if ($GLOBALS['xoopsModuleConfig']['show_sociallinks']) {
611
            $full_title  = $this->getVar('subject');
612
            $clean_title = \preg_replace('/[^A-Za-z0-9-]+/', '+', $this->getVar('subject'));
613
            $full_link   = $GLOBALS['xoops']->url("modules/newbb/viewtopic.php?post_id={$post_id}");
614
615
            $thread_action['social_twitter']['image']  = newbb_displayImage('twitter', \_MD_SHARE_TWITTER);
616
            $thread_action['social_twitter']['link']   = "http://twitter.com/share?text={$clean_title}&amp;url={$full_link}";
617
            $thread_action['social_twitter']['name']   = \_MD_SHARE_TWITTER;
618
            $thread_action['social_twitter']['target'] = '_blank';
619
620
            $thread_action['social_facebook']['image']  = newbb_displayImage('facebook', \_MD_SHARE_FACEBOOK);
621
            $thread_action['social_facebook']['link']   = "http://www.facebook.com/sharer.php?u={$full_link}";
622
            $thread_action['social_facebook']['name']   = \_MD_SHARE_FACEBOOK;
623
            $thread_action['social_facebook']['target'] = '_blank';
624
625
            $thread_action['social_gplus']['image']  = newbb_displayImage('googleplus', \_MD_SHARE_GOOGLEPLUS);
626
            $thread_action['social_gplus']['link']   = "https://plusone.google.com/_/+1/confirm?hl=en&url={$full_link}";
627
            $thread_action['social_gplus']['name']   = \_MD_SHARE_GOOGLEPLUS;
628
            $thread_action['social_gplus']['target'] = '_blank';
629
630
            $thread_action['social_linkedin']['image']  = newbb_displayImage('linkedin', \_MD_SHARE_LINKEDIN);
631
            $thread_action['social_linkedin']['link']   = "http://www.linkedin.com/shareArticle?mini=true&amp;title={$full_title}&amp;url={$full_link}";
632
            $thread_action['social_linkedin']['name']   = \_MD_SHARE_LINKEDIN;
633
            $thread_action['social_linkedin']['target'] = '_blank';
634
635
            $thread_action['social_delicious']['image']  = newbb_displayImage('delicious', \_MD_SHARE_DELICIOUS);
636
            $thread_action['social_delicious']['link']   = "http://del.icio.us/post?title={$full_title}&amp;url={$full_link}";
637
            $thread_action['social_delicious']['name']   = \_MD_SHARE_DELICIOUS;
638
            $thread_action['social_delicious']['target'] = '_blank';
639
640
            $thread_action['social_digg']['image']  = newbb_displayImage('digg', \_MD_SHARE_DIGG);
641
            $thread_action['social_digg']['link']   = "http://digg.com/submit?phase=2&amp;title={$full_title}&amp;url={$full_link}";
642
            $thread_action['social_digg']['name']   = \_MD_SHARE_DIGG;
643
            $thread_action['social_digg']['target'] = '_blank';
644
645
            $thread_action['social_reddit']['image']  = newbb_displayImage('reddit', \_MD_SHARE_REDDIT);
646
            $thread_action['social_reddit']['link']   = "http://reddit.com/submit?title={$full_title}&amp;url={$full_link}";
647
            $thread_action['social_reddit']['name']   = \_MD_SHARE_REDDIT;
648
            $thread_action['social_reddit']['target'] = '_blank';
649
650
            $thread_action['social_wong']['image']  = newbb_displayImage('wong', \_MD_SHARE_MRWONG);
651
            $thread_action['social_wong']['link']   = "http://www.mister-wong.de/index.php?action=addurl&bm_url=$full_link}";
652
            $thread_action['social_wong']['name']   = \_MD_SHARE_MRWONG;
653
            $thread_action['social_wong']['target'] = '_blank';
654
        }
655
656
        $post = [
657
            'post_id'         => $post_id,
658
            'post_parent_id'  => $this->getVar('pid'),
659
            'post_date'       => newbb_formatTimestamp($this->getVar('post_time')),
0 ignored issues
show
Bug introduced by
The function newbb_formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

659
            'post_date'       => /** @scrutinizer ignore-call */ newbb_formatTimestamp($this->getVar('post_time')),
Loading history...
660
            'post_image'      => $post_image,
661
            'post_title'      => $post_title,        // irmtfan $post_title to add highlight keywords
662
            'post_text'       => $post_text,
663
            'post_attachment' => $post_attachment,
664
            'post_edit'       => $this->displayPostEdit(),
665
            'post_no'         => $post_no,
666
            'post_signature'  => $this->getVar('attachsig') ? @$poster['signature'] : '',
667
            'poster_ip'       => ($isadmin
668
                                  && $GLOBALS['xoopsModuleConfig']['show_ip']) ? \long2ip($this->getVar('poster_ip')) : '',
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('poster_ip') can also be of type array and array; however, parameter $proper_address of long2ip() 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 ignore-type  annotation

668
                                  && $GLOBALS['xoopsModuleConfig']['show_ip']) ? \long2ip(/** @scrutinizer ignore-type */ $this->getVar('poster_ip')) : '',
Loading history...
669
            'thread_action'   => $thread_action,
670
            'thread_buttons'  => $thread_buttons,
671
            'mod_buttons'     => $mod_buttons,
672
            'poster'          => $poster,
673
            'post_permalink'  => "<a href='" . $GLOBALS['xoops']->url('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/viewtopic.php?post_id={$post_id}") . "'></a>",
674
        ];
675
676
        unset($thread_buttons, $mod_buttons, $eachposter);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $eachposter does not exist. Did you maybe mean $poster?
Loading history...
677
678
        return $post;
679
    }
680
}
681