Issues (134)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.
Severity
1
<?php
2
//
3
//  ------------------------------------------------------------------------ //
4
//             XF Guestbook                                                  //
5
// ------------------------------------------------------------------------- //
6
//  This program is free software; you can redistribute it and/or modify     //
7
//  it under the terms of the GNU General Public License as published by     //
8
//  the Free Software Foundation; either version 2 of the License, or        //
9
//  (at your option) any later version.                                      //
10
//                                                                           //
11
//  You may not change or alter any portion of this comment or credits       //
12
//  of supporting developers from this source code or any supporting         //
13
//  source code which is considered copyrighted (c) material of the          //
14
//  original comment or credit authors.                                      //
15
//                                                                           //
16
//  This program is distributed in the hope that it will be useful,          //
17
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
18
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
19
//  GNU General Public License for more details.                             //
20
//                                                                           //
21
//  You should have received a copy of the GNU General Public License        //
22
//  along with this program; if not, write metalslugto the Free Software              //
23
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
24
//  ------------------------------------------------------------------------ //
25
26
use Xmf\Request;
27
use XoopsModules\Xfguestbook;
28
use XoopsModules\Xfguestbook\Helper;
29
30
$GLOBALS['xoopsOption']['template_main'] = 'xfguestbook_index.tpl';
31
32
require_once __DIR__ . '/header.php';
33
34
//** @var Helper $helper */
35
$helper = Helper::getInstance();
36
37
if (Request::hasVar('msg_id', 'GET')) {
38
    $msg_id = Request::getInt('msg_id', 0, 'GET');
39
} else {
40
    $msg_id = Request::getInt('msg_id', 0, 'POST');
41
}
42
43
$op = 'show_all';
44
if (Request::hasVar('op', 'GET')) {
45
    $op = Request::getString('op', '', 'GET');
46
} elseif (Request::hasVar('op', 'POST')) {
47
    $op = Request::getString('op', '', 'POST');
48
}
49
50
/** @var \XoopsModules\Xfguestbook\MessageHandler $msgHandler */
51
$msgHandler = $helper->getHandler('Message');
52
53
//Admin or not
54
$xoopsUser ? $adminview = $xoopsUser->isAdmin() : $adminview = 0;
55
56
/**
57
 * @param $msg_id
58
 */
59
function delete($msg_id)
60
{
61
    global $msgHandler, $xoopsModule;
62
    $ok = Request::getInt('ok', 0, 'POST');
63
    if (1 == $ok) {
64
        $msg        = $msgHandler->get($msg_id);
65
        $del_msg_ok = $msgHandler->delete($msg);
66
        $filename   = $msg->getVar('photo');
67
        if ('' !== $filename) {
68
            $filename = XOOPS_UPLOAD_PATH . '/' . $xoopsModule->getVar('dirname') . '/' . $filename;
69
            unlink($filename);
70
        }
71
        if ($del_msg_ok) {
72
            $messagesent = MD_XFGUESTBOOK_MSGDELETED;
73
        } else {
74
            $messagesent = MD_XFGUESTBOOK_ERRORDEL;
75
        }
76
        redirect_header('index.php', 2, $messagesent);
77
    } else {
78
        xoops_confirm(['op' => 'delete', 'msg_id' => $msg_id, 'ok' => 1], 'index.php', _DELETE);
79
    }
80
}
81
82
/**
83
 * @param $msg_id
84
 */
85
function approve($msg_id)
86
{
87
    global $msgHandler;
88
89
    $msg = $msgHandler->get($msg_id);
90
    $msg->setVar('moderate', 0);
91
    if (!$msgHandler->insert($msg)) {
92
        $messagesent = MD_XFGUESTBOOK_ERRORVALID;
93
    } else {
94
        $messagesent = MD_XFGUESTBOOK_VALIDATE;
95
    }
96
    redirect_header('index.php?op=show_waiting', 2, $messagesent);
97
}
98
99
/**
100
 * @param $msg
101
 */
102
function xfgb_getmsg($msg)
103
{
104
    global $nbmsg, $xoopsModule, $xoopsUser, $xoopsTpl, $xoopsConfig, $options, $opt, $xoopsDB;
105
    /** @var Helper $helper */
106
    $helper = Helper::getInstance();
107
108
    $arr_country = Xfguestbook\Utility::getAllCountry();
109
    $xoopsTpl->assign('display_msg', true);
110
    foreach ($msg as $onemsg) {
111
        $poster = Xfguestbook\Utility::get_user_data($onemsg->getVar('user_id'));
112
        if ($poster) {
113
            $a_msg = &$poster;
114
        } else {
115
            $a_msg             = [];
116
            $a_msg['poster']   = $onemsg->getVar('uname');
117
            $a_msg['rank']     = '';
118
            $a_msg['rank_img'] = '';
119
            $a_msg['avatar']   = '';
120
        }
121
        /** @var \XoopsMemberHandler $memberHandler */
122
        $memberHandler = xoops_getHandler('member');
123
        $user          = $memberHandler->getUser($onemsg->getVar('user_id'));
124
        // email
125
        if ($helper->getConfig('showemail')
126
            || ($onemsg->getVar('email')
127
                && ((1 == $user->getVar('user_viewemail')
128
                     || 0 == $onemsg->getVar('user_id'))
129
                    && is_object($xoopsUser)))) {
130
            $a_msg['email'] = "<a href=\"javascript:openWithSelfMain('" . XOOPS_URL . '/modules/xfguestbook/contact.php?msg_id=' . $onemsg->getVar('msg_id') . '\', \'contact\', 600, 450);"><img src="' . XOOPS_URL . '/images/icons/email.gif" alt="' . _SENDEMAILTO . '"></a>';
131
        }
132
        // url
133
        if ($onemsg->getVar('url')) {
134
            $a_msg['url'] = '<a href="' . $onemsg->getVar('url') . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" alt="' . _VISITWEBSITE . '"></a>';
135
        }
136
        // gender
137
        if ('' !== $onemsg->getVar('gender')) {
138
            $a_msg['gender'] = '<a href="index.php?op=show_gender&param=' . $onemsg->getVar('gender') . '"><img src="assets/images/' . $onemsg->getVar('gender') . '.gif"</a>';
139
        }
140
        // flag
141
        $country_name = '';
142
        if ('' !== $onemsg->getVar('country')) {
143
            if ('other' !== $onemsg->getVar('country')) {
144
                $flag = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/assets/images/flags/' . $onemsg->getVar('flagdir') . '/' . $onemsg->getVar('country') . '.gif';
145
                if (array_key_exists($onemsg->getVar('flagdir') . '/' . $onemsg->getVar('country'), $arr_country)) {
146
                    $country_name = $arr_country[$onemsg->getVar('flagdir') . '/' . $onemsg->getVar('country')];
147
                }
148
                if (file_exists($flag)) {
149
                    $a_msg['country'] = '<img src="' . XOOPS_URL . '/modules/xfguestbook/assets/images/flags/' . $onemsg->getVar('flagdir') . '/' . $onemsg->getVar('country') . '.gif" alt="' . $country_name . '">';
150
                } else {
151
                    $a_msg['country'] = $country_name;
152
                }
153
                $a_msg['country'] = '<a href="index.php?op=show_country&param=' . $onemsg->getVar('flagdir') . '/' . $onemsg->getVar('country') . '">' . $a_msg['country'] . '</a>';
154
            } else {
155
                $a_msg['country'] = $onemsg->getVar('other');
156
            }
157
        }
158
        $a_msg['msg_id']  = $onemsg->getVar('msg_id');
159
        $a_msg['i']       = $nbmsg;
160
        $a_msg['title']   = $onemsg->getVar('title');
161
        $a_msg['date']    = formatTimestamp($onemsg->getVar('post_time'), 's');
162
        $a_msg['message'] = $onemsg->getVar('message');
163
        if (1 == $options['opt_url']) {
164
            $a_msg['message'] = str_replace('target="_blank"', 'target="_blank" rel="nofollow"', $a_msg['message']);
165
        }
166
        $a_msg['note_msg']  = $onemsg->getVar('note');
167
        $a_msg['poster_ip'] = $onemsg->getVar('poster_ip');
168
        $a_msg['moderate']  = $onemsg->getVar('moderate');
169
        if (null !== $country_name) {
170
            $a_msg['local'] = '<a href="index.php?op=show_country&param=' . $onemsg->getVar('flagdir') . '/' . $onemsg->getVar('country') . '">' . $country_name . '</a>';
171
        }
172
        $a_msg['photo'] = $onemsg->getVar('photo');
173
        $xoopsTpl->append('msg', $a_msg);
174
        $nbmsg--;
175
    }
176
}
177
178
function xfgb_genderlist()
179
{
180
    global $options, $xoopsTpl, $xoopsModule, $msgHandler;
181
    /** @var Helper $helper */
182
    $helper   = Helper::getInstance();
0 ignored issues
show
The assignment to $helper is dead and can be removed.
Loading history...
183
    $criteria = new \Criteria('moderate', 0);
184
    $arr_msg  = $msgHandler->countMsgByGender($criteria);
185
    $i        = 0;
186
    $gender   = [];
187
    foreach ($arr_msg as $k => $v) {
188
        if ('M' === $k) {
189
            $gender[$i] = MD_XFGUESTBOOK_MALES . '<br>';
190
            $gender[$i] .= '<img src="assets/images/M.gif" alt="' . MD_XFGUESTBOOK_MALES . '"><br><br>';
191
            $gender[$i] .= '<a href="index.php?op=show_gender&param=M">' . $v . MD_XFGUESTBOOK_MESSAGES . '</a>';
192
        } elseif ('F' === $k) {
193
            $gender[$i] = MD_XFGUESTBOOK_FEMALES . '<br>';
194
            $gender[$i] .= '<img src="assets/images/F.gif" alt="' . MD_XFGUESTBOOK_FEMALES . '"><br><br>';
195
            $gender[$i] .= '<a href="index.php?op=show_gender&param=F">' . $v . MD_XFGUESTBOOK_MESSAGES . '</a>';
196
        } else {
197
            $gender[$i] = MD_XFGUESTBOOK_UNKNOW2 . '<br>';
198
            $gender[$i] .= '<img src="assets/images/U.gif"><br><br>';
199
            $gender[$i] .= $v . MD_XFGUESTBOOK_MESSAGES;
200
        }
201
        $i++;
202
    }
203
    $xoopsTpl->assign('gender', $gender);
204
    $xoopsTpl->assign('display_gender', $options['opt_gender']);
205
}
206
207
// end functions
208
209
// if op = show_***, functions needed
210
//if (substr($op, 0, 4) == 'show') {
211
if (0 === strncmp($op, 'show', 4)) {
212
    $debut = Request::getInt('debut', 0, 'GET');
213
    $param = Request::getString('param', '', 'GET');
214
215
    require_once XOOPS_ROOT_PATH . '/header.php';
216
    require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
217
    require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/include/config.inc.php';
218
    $options = getOptions();
219
220
    $criteria = new \Criteria('moderate', 0);
221
    $nbmsg    = $msgHandler->countMsg($criteria);
222
223
    $xoopsTpl->assign('msg_message_count', sprintf(MD_XFGUESTBOOK_THEREIS, '<b>' . $nbmsg . '</b>'));
224
    $xoopsTpl->assign('msg_moderated', $helper->getConfig('moderate'));
225
    $xoopsTpl->assign('msg_lang_name', $xoopsConfig['language']);
226
    $xoopsTpl->assign('xoops_pagetitle', $xoopsModule->name() . ' -messages');
227
    if ($adminview) {
228
        $nbwait = $msgHandler->countMsg(new \Criteria('moderate', '1'));
229
        $xoopsTpl->assign('msg_moderate_text', sprintf(MD_XFGUESTBOOK_MODERATING, "<span class='fg2'><a href='" . XOOPS_URL . "/modules/xfguestbook/index.php?op=show_waiting'>" . $nbwait . '</a></span>'));
230
    }
231
}
232
233
switch ($op) {
234
    case 'delete':
235
        if ($adminview) {
236
            require_once XOOPS_ROOT_PATH . '/header.php';
237
            delete($msg_id);
238
        } else {
239
            redirect_header('index.php', 1, '');
240
        }
241
        break;
242
    case 'approve':
243
        if ($adminview) {
244
            require_once XOOPS_ROOT_PATH . '/header.php';
245
            approve($msg_id);
246
        } else {
247
            redirect_header('index.php', 1, '');
248
        }
249
        break;
250
    case 'show_stat':
251
        if ($options['opt_gender'] > 0) {
252
            xfgb_genderlist();
253
        }
254
        break;
255
    case 'show_waiting':
256
        $pagenav = new \XoopsPageNav($nbwait, $helper->getConfig('perpage'), $debut, 'debut', 'op=show_waiting');
257
        $xoopsTpl->assign('msg_page_nav', $pagenav->renderNav());
258
        $criteria = new \Criteria('moderate', 1);
259
        $criteria->setOrder('DESC');
260
        $criteria->setLimit($helper->getConfig('perpage'));
261
        $criteria->setStart($debut);
262
        $msg    = $msgHandler->getObjects($criteria);
263
        $nbwait -= $debut;
264
        $nbmsg  = $nbwait;
265
        xfgb_getmsg($msg);
266
        break;
267
    case 'show_one':
268
        if ($adminview) {
269
            $criteria = new \Criteria('msg_id', $msg_id);
270
        } else {
271
            $criteria = new \CriteriaCompo(new \Criteria('moderate', '0'));
272
            $criteria->add(new \Criteria('msg_id', $msg_id));
273
        }
274
        $msg = $msgHandler->getObjects($criteria);
275
        xfgb_getmsg($msg);
276
        if ($options['opt_gender'] > 0) {
277
            xfgb_genderlist();
278
        }
279
        break;
280
    case 'show_country':
281
        [$flagdir, $country] = explode('/', $param);
282
        $criteria = new \CriteriaCompo(new \Criteria('moderate', '0'));
283
        if ($flagdir == $helper->getConfig('flagdir')) {
284
            $criteria->add(new \Criteria('flagdir', $flagdir));
285
        }
286
        $criteria->add(new \Criteria('country', $country));
287
        $nbmsg   = $msgHandler->countMsg($criteria);
288
        $pagenav = new \XoopsPageNav($nbmsg, $helper->getConfig('perpage'), $debut, 'debut', 'op=show_country&param=' . $param);
289
        $criteria->setOrder('DESC');
290
        $criteria->setLimit($helper->getConfig('perpage'));
291
        $criteria->setStart($debut);
292
        $msg   = $msgHandler->getObjects($criteria);
293
        $nbmsg -= $debut;
294
        $xoopsTpl->assign('msg_page_nav', $pagenav->renderNav());
295
        xfgb_getmsg($msg);
296
        break;
297
    case 'show_gender':
298
        $criteria = new \CriteriaCompo(new \Criteria('moderate', '0'));
299
        $criteria->add(new \Criteria('gender', $param));
300
        $nbmsg   = $msgHandler->countMsg($criteria);
301
        $pagenav = new \XoopsPageNav($nbmsg, $helper->getConfig('perpage'), $debut, 'debut', 'op=show_gender&param=' . $param);
302
        $criteria->setOrder('DESC');
303
        $criteria->setLimit($helper->getConfig('perpage'));
304
        $criteria->setStart($debut);
305
        $msg   = $msgHandler->getObjects($criteria);
306
        $nbmsg -= $debut;
307
        $xoopsTpl->assign('msg_page_nav', $pagenav->renderNav());
308
        xfgb_getmsg($msg);
309
        if ($options['opt_gender'] > 0) {
310
            xfgb_genderlist();
311
        }
312
        break;
313
    case 'show_all':
314
    default:
315
        $pagenav = new \XoopsPageNav($nbmsg, $helper->getConfig('perpage'), $debut, 'debut', '');
316
        $xoopsTpl->assign('msg_page_nav', $pagenav->renderNav());
317
        $criteria = new \Criteria('moderate', 0);
318
        $criteria->setOrder('DESC');
319
        $criteria->setLimit($helper->getConfig('perpage'));
320
        $criteria->setStart($debut);
321
        $msg   = $msgHandler->getObjects($criteria);
322
        $nbmsg -= $debut;
323
        xfgb_getmsg($msg);
324
        if ($options['opt_gender'] > 0) {
325
            xfgb_genderlist();
326
        }
327
        break;
328
    case 'cancel':
329
        $photos_dir     = XOOPS_UPLOAD_PATH . '/' . $xoopsModule->getVar('dirname');
330
        $nb_removed_tmp = Xfguestbook\Utility::clear_tmp_files($photos_dir);
331
        redirect_header('index.php', 0);
332
        break;
333
}
334
335
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('xfguestbook_country') . ' ORDER BY country_name ASC';
336
$result = $xoopsDB->query($sql);
337
338
while (false !== ($coun = $xoopsDB->fetchArray($result))) {
339
    $sql2 = 'SELECT COUNT(country) tot FROM ' . $xoopsDB->prefix('xfguestbook_msg') . " WHERE country='" . $coun['country_code'] . '\'';
340
    $result2 = $xoopsDB->query($sql2);
341
    [$tlocal] = $xoopsDB->fetchRow($result2);
342
    $tlocal = $tlocal ?: '0';
343
    if ($tlocal > 0) {
344
        $opt['<a href="index.php?op=show_country&param=' . $helper->getConfig('flagdir') . '/' . $coun['country_code'] . '">' . $coun['country_name'] . '</a>'] = $tlocal;
345
    } else {
346
        $opt[$coun['country_name']] = $tlocal;
347
    }
348
}
349
$xoopsTpl->assign('country_l', $opt);
350
351
require_once XOOPS_ROOT_PATH . '/footer.php';
352