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.

admin/ip_manager.php (9 issues)

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 to the Free Software              //
23
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
24
//  ------------------------------------------------------------------------ //
25
26
use Xmf\Module\Admin;
27
use Xmf\Request;
28
use XoopsModules\Xfguestbook;
29
30
require_once __DIR__ . '/admin_header.php';
31
require_once dirname(__DIR__, 3) . '/include/cp_header.php';
32
require_once dirname(__DIR__) . '/include/cp_functions.php';
33
34
$op = 'badIpShow';
35
if (Request::hasVar('op', 'GET')) {
36
    $op = $_GET['op'];
37
} elseif (Request::hasVar('op', 'POST')) {
38
    $op = $_POST['op'];
39
}
40
41
if (Request::hasVar('ip_id', 'GET')) {
42
    $ip_id = Request::getInt('ip_id', 0, 'GET');
43
} else {
44
    $ip_id = Request::getInt('ip_id', 0, 'POST');
45
}
46
47
$ip_value = Request::getString('ip_value', '', 'POST');
48
49
/**
50
 * @param $ip_id
51
 */
52
function badIpDel($ip_id)
0 ignored issues
show
The parameter $ip_id 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

52
function badIpDel(/** @scrutinizer ignore-unused */ $ip_id)

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...
53
{
54
    global $xoopsDB;
55
    $ip_count = (!empty($_POST['ip_id']) && is_array($_POST['ip_id'])) ? count($_POST['ip_id']) : 0;
56
    if ($ip_count > 0) {
57
        $messagesent = AM_XFGUESTBOOK_BADIP_DELETED;
58
        for ($i = 0; $i < $ip_count; $i++) {
59
            $sql = sprintf('DELETE FROM `%s` WHERE ip_id = %u', $xoopsDB->prefix('xfguestbook_badips'), $_POST['ip_id'][$i]);
60
            if (!$result = $xoopsDB->query($sql)) {
0 ignored issues
show
The assignment to $result is dead and can be removed.
Loading history...
61
                $messagesent = AM_XFGUESTBOOK_ERRORDEL;
62
            }
63
        }
64
    } else {
65
        $messagesent = AM_XFGUESTBOOK_NOBADIP;
66
    }
67
    redirect_header($_SERVER['SCRIPT_NAME'], 2, $messagesent);
68
}
69
70
/**
71
 * @param null $ip_id
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $ip_id is correct as it would always require null to be passed?
Loading history...
72
 */
73
function badIpForm($ip_id = null)
74
{
75
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
76
    if ($ip_id) {
0 ignored issues
show
$ip_id is of type null, thus it always evaluated to false.
Loading history...
77
        $sform    = new \XoopsThemeForm(AM_XFGUESTBOOK_MOD_BADIP, 'op', xoops_getenv('SCRIPT_NAME'), 'post', true);
78
        $badips   = Xfguestbook\Utility::get_badips(true);
79
        $ip_value = $badips[$ip_id]['ip_value'];
80
    } else {
81
        $sform    = new \XoopsThemeForm(AM_XFGUESTBOOK_ADD_BADIP, 'op', xoops_getenv('SCRIPT_NAME'), 'post', true);
82
        $ip_value = '';
83
    }
84
85
    $sform->addElement(new \XoopsFormText(AM_XFGUESTBOOK_VALUE, 'ip_value', 50, 50, $ip_value), true);
86
87
    $buttonTray = new \XoopsFormElementTray('', '');
88
    $buttonTray->addElement(new \XoopsFormButton('', 'save', _SUBMIT, 'submit'));
89
    if ($ip_id) {
0 ignored issues
show
$ip_id is of type null, thus it always evaluated to false.
Loading history...
90
        $buttonTray->addElement(new \XoopsFormHidden('ip_id', $ip_id));
91
    }
92
    $buttonTray->addElement(new \XoopsFormHidden('op', 'badIpSave'));
93
    $sform->addElement($buttonTray);
94
    $sform->display();
95
}
96
97
/**
98
 * @param $ip_id
99
 * @param $ip_value
100
 */
101
function badIpSave($ip_id, $ip_value)
102
{
103
    global $xoopsDB;
104
105
    $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
The assignment to $myts is dead and can be removed.
Loading history...
106
    //$ip_value=$myts->addSlashes($ip_value);
107
    if (!empty($ip_id)) {
108
        $sql = 'UPDATE ' . $xoopsDB->prefix('xfguestbook_badips') . " SET ip_id='$ip_id', ip_value='$ip_value'";
109
        $sql .= " WHERE ip_id = $ip_id";
110
        $xoopsDB->query($sql);
111
        $messagesent = AM_XFGUESTBOOK_BADIP_UPDATED;
112
    } else {
113
        $sql = sprintf("SELECT COUNT(*) FROM  %s WHERE ip_value = '%s'", $xoopsDB->prefix('xfguestbook_badips'), $ip_value);
114
        [$count] = $xoopsDB->fetchRow($xoopsDB->query($sql));
115
        if ($count > 0) {
116
            $messagesent = '<span style="color: #FF0000; ">' . AM_XFGUESTBOOK_BADIP_EXIST . '</span>';
117
        } else {
118
            $country_id = $xoopsDB->genId('ip_id_seq');
0 ignored issues
show
The assignment to $country_id is dead and can be removed.
Loading history...
119
            $sql        = sprintf("INSERT INTO `%s` (ip_id, ip_value) VALUES (%s, '%s')", $xoopsDB->prefix('xfguestbook_badips'), $ip_id, $ip_value);
120
            $xoopsDB->query($sql);
121
            $messagesent = AM_XFGUESTBOOK_BADIP_ADDED;
122
        }
123
    }
124
    redirect_header('ip_manager.php', 2, $messagesent);
125
}
126
127
function badIpShow()
128
{
129
    global $action, $start, $xoopsModule, $xoopsModuleConfig;
130
    $myts      = \MyTextSanitizer::getInstance();
0 ignored issues
show
The assignment to $myts is dead and can be removed.
Loading history...
131
    $limit     = 15;
0 ignored issues
show
The assignment to $limit is dead and can be removed.
Loading history...
132
    $badips    = Xfguestbook\Utility::get_badips(true);
133
    $nb_badips = count($badips);
134
135
    echo "
136
    <table width='100%' cellspacing='1' cellpadding='2' border='0' style='border-left: 1px solid #c0c0c0; border-top: 1px solid #c0c0c0; border-right: 1px solid #c0c0c0;'>
137
        <tr>
138
            <td><span style='font-weight: bold; font-size: 12px; font-variant: small-caps;'>" . AM_XFGUESTBOOK_DISP_BADIPS . ' : ' . $nb_badips . "</span></td>
139
            <td align='right'>
140
            </td>
141
        </tr>
142
    </table>";
143
144
    echo "<table border='1' width='100%' cellpadding ='2' cellspacing='1'>";
145
    echo "<tr class='bg3'>";
146
    echo '<td></td>';
147
    echo "<td align='center'><b>" . AM_XFGUESTBOOK_IPS . '</td>';
148
    echo "<td align='center'><b>" . AM_XFGUESTBOOK_ACTION . '</td>';
149
    echo '</tr>';
150
151
    if ('0' != count($badips)) {
152
        echo "<form name='badiplist' id='list' action='" . $_SERVER['SCRIPT_NAME'] . '\' method=\'POST\' style=\'margin: 0;\'>';
153
154
        for ($i = 0; $i < $nb_badips; $i++) {
155
            echo '<tr>';
156
            echo "<td align='center' class='even'><input type='checkbox' name='ip_id[]' id='ip_id[]' value='" . $badips[$i]['ip_id'] . '\'></td>';
157
            echo "<td class = 'odd'>" . $badips[$i]['ip_value'] . '</td>';
158
            echo "<td align='center' class='even'><a href='ip_manager.php?op=badIpEdit&amp;ip_id=" . $badips[$i]['ip_id'] . '\'>' . _EDIT . '</a></td>';
159
            echo '</tr>';
160
            //          unset($badips);
161
        }
162
        echo "<tr class='foot'><td><select name='op'>";
163
        echo "<option value='badIpDel'>" . _DELETE . '</option>';
164
        echo '</select>&nbsp;</td>';
165
        echo "<td colspan='3'>" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "<input type='submit' value='" . _GO . '\'>';
166
        echo '</td></tr>';
167
        echo '</form>';
168
    } else {
169
        echo "<tr ><td align='center' colspan ='3' class = 'head'><b>" . AM_XFGUESTBOOK_NOBADIP . '</b></td></tr>';
170
    }
171
    echo '</table><br>';
172
    echo '<br>';
173
}
174
175
switch ($op) {
176
    case 'badIpForm':
177
        xoops_cp_header();
178
        $adminObject = Admin::getInstance();
179
        $adminObject->displayNavigation(basename(__FILE__));
180
        //xfguestbook_admin_menu(3);
181
        badIpForm($ip_id);
182
        require_once __DIR__ . '/admin_footer.php';
183
        //xoops_cp_footer();
184
        break;
185
    case 'badIpDel':
186
        badIpDel($ip_id);
187
        break;
188
    case 'badIpEdit':
189
        xoops_cp_header();
190
        $adminObject = Admin::getInstance();
191
        $adminObject->displayNavigation(basename(__FILE__));
192
        //xfguestbook_admin_menu(3);
193
        badIpForm($ip_id);
194
        require_once __DIR__ . '/admin_footer.php';
195
        //xoops_cp_footer();
196
        break;
197
    case 'badIpSave':
198
        badIpSave($ip_id, $ip_value);
199
        break;
200
    case 'badIpAdd':
201
        xoops_cp_header();
202
        $adminObject = Admin::getInstance();
203
        $adminObject->displayNavigation(basename(__FILE__));
204
        //xfguestbook_admin_menu(3);
205
        badIpForm();
206
        require_once __DIR__ . '/admin_footer.php';
207
        //xoops_cp_footer();
208
        break;
209
    case 'badIpShow':
210
    default:
211
        xoops_cp_header();
212
        $adminObject = Admin::getInstance();
213
        $adminObject->displayNavigation(basename(__FILE__));
214
        //xfguestbook_admin_menu(3);
215
        badIpShow();
216
        badIpForm();
217
        require_once __DIR__ . '/admin_footer.php';
218
        //xoops_cp_footer();
219
        break;
220
}
221