Issues (102)

Security Analysis    no request data  

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

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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/main.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits of
4
 supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit
6
 authors.
7
8
 This program is distributed in the hope that it will be useful, but
9
 WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * Module: RandomQuote
14
 *
15
 * @category        Module
16
 * @package         randomquote
17
 * @author          XOOPS Module Development Team
18
 * @author          Mamba
19
 * @copyright       {@link https://xoops.org 2001-2016 XOOPS Project}
20
 * @license         {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
21
 * @link            https://xoops.org XOOPS
22
 * @since           2.00
23
 */
24
use Xmf\Request;
25
26
require_once __DIR__ . '/admin_header.php';
27
xoops_cp_header();
28
29
$op = Request::getCmd('op', '');
30
31
switch ($op) {
32
    case 'list':
33
    default:
34
       $adminObject->displayNavigation(basename(__FILE__));
35
       $adminObject->addItemButton(_AM_RANDOMQUOTE_NEW_QUOTES, 'main.php?op=new_quote', 'add');
36
       $adminObject->displayButton('left');
37
        $criteria = new CriteriaCompo();
38
        if (isset($_REQUEST['status'])) {
39
            $status = Request::getInt('status', RandomquoteConstants::STATUS_ONLINE);
40
            $criteria->add(new Criteria('quote_status', $status));
41
        } else {
42
            $criteria->setSort('id');
43
        }
44
        $criteria->setOrder('ASC');
45
        $quotesObjArray = $quotesHandler->getAll($criteria);
46
        $quoteCount     = (!empty($quotesObjArray) ? count($quotesObjArray) : 0);
47
48
        //Table view
49
        if ($quoteCount) {
50
            echo "\n"
51
                 . "<table class='outer width100 bspacing1'>\n"
52
                 . "<thead>\n"
53
                 . "  <tr>\n"
54
                 . "    <th class='txtcenter width5'>"
55
                 . _AM_RANDOMQUOTE_QUOTES_STATUS
56
                 . "</th>\n"
57
                 . "    <th class='txtcenter width10'>"
58
                 . _AM_RANDOMQUOTE_QUOTES_DATE
59
                 . "</th>\n"
60
                 . "    <th class='txtcenter'>"
61
                 . _AM_RANDOMQUOTE_QUOTES_QUOTE
62
                 . "</th>\n"
63
                 . "    <th class='txtcenter width20'>"
64
                 . _AM_RANDOMQUOTE_QUOTES_AUTHOR
65
                 . "</th>\n"
66
                 . "    <th class='txtcenter width10'>"
67
                 . _AM_RANDOMQUOTE_FORMACTION
68
                 . "</th>\n"
69
                 . "  </tr>\n"
70
                 . "  </thead>\n"
71
                 . "  <tbody>\n";
72
73
            $class = 'even';
74
75
            $statusIcons = array(RandomquoteConstants::STATUS_OFFLINE => array('image' => 'off.png', 'text' => _AM_RANDOMQUOTE_QUOTES_OFFLINE_TXT),
76
                                 RandomquoteConstants::STATUS_ONLINE  => array('image' => 'on.png', 'text' => _AM_RANDOMQUOTE_QUOTES_ONLINE_TXT),
77
                                 RandomquoteConstants::STATUS_WAITING => array('image' => 'warning.png', 'text' => _AM_RANDOMQUOTE_QUOTES_WAITING_TXT));
78
            foreach ($quotesObjArray as $quoteObj) {
79
                //            foreach (array_keys($quotes_arr) as $i) {
80
                $class             = ('even' == $class) ? 'odd' : 'even';
81
                $thisStatus        = $quoteObj->getVar('quote_status');
82
                $quote_status_link = "<img src='{$pathIcon16}/{$statusIcons[$thisStatus]['image']}'" . " alt='{$statusIcons[$thisStatus]['text']}'" . " title='{$statusIcons[$thisStatus]['text']}'>";
83
                echo "  <tr class='{$class}'>\n"
84
                     . "    <td class='txtcenter'>"
85
                     . $quote_status_link
86
                     . "</td>\n"
87
                     . "    <td class='txtcenter'>"
88
                     . ucfirst(formatTimestamp(strtotime($quoteObj->getVar('create_date')), 'm'))
89
                     . "</td>\n"
90
                     . '    <td>'
91
                     . $quoteObj->getVar('quote')
92
                     . "</td>\n"
93
                     . "    <td class='txtcenter'>"
94
                     . $quoteObj->getVar('author')
95
                     . "</td>\n"
96
                     . "    <td class='txtcenter'>\n"
97
                     . "      <a href='./main.php?op=edit_quote&id="
98
                     . $quoteObj->getVar('id')
99
                     . "'><img src='{$pathIcon16}/edit.png' alt='"
100
                     . _EDIT
101
                     . "' title='"
102
                     . _EDIT
103
                     . "'></a>\n"
104
                     . "      <a href='./main.php?op=delete_quote&id="
105
                     . $quoteObj->getVar('id')
106
                     . "'><img src='{$pathIcon16}/delete.png' alt='"
107
                     . _DELETE
108
                     . "' title='"
109
                     . _DELETE
110
                     . "'></a>\n"
111
                     . "    </td>\n"
112
                     . "  </tr>\n";
113
            }
114
            echo "  </tbody>\n" . "</table><br><br>\n";
115
        } else {
116
            //no quotes in the dB
117
            echo "<div class=\"clear spacer;\"> </div>\n"
118
                 . '<div class="center bold italic large line180">'
119
                 . sprintf(_AM_RANDOMQUOTE_THEREARE_QUOTES, _NO)
120
                 . "</div>\n"
121
                 . "<div class=\"clear spacer line180\"> </div>\n";
122
        }
123
        break;
124
125 View Code Duplication
    case 'new_quote':
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
126
       $adminObject->displayNavigation(basename(__FILE__));
127
       $adminObject->addItemButton(_AM_RANDOMQUOTE_QUOTES_LIST, 'main.php?op=list', 'list');
128
       $adminObject->displayButton('left');
129
130
        $obj  = $quotesHandler->create();
131
        $form = $obj->getForm();
132
        $form->display();
133
        break;
134
135
    case 'save_quote':
136
        // check to make sure this passes form submission security
137 View Code Duplication
        if ($GLOBALS['xoopsSecurity'] instanceof XoopsSecurity) {
138
            if (!$GLOBALS['xoopsSecurity']->check()) {
139
                // failed xoops security check
140
                redirect_header($_SERVER['PHP_SELF'], RandomquoteConstants::REDIRECT_DELAY_MEDIUM, $GLOBALS['xoopsSecurity']->getErrors(true));
141
            }
142
        } else {
143
            redirect_header('index.php', RandomquoteConstants::REDIRECT_DELAY_MEDIUM, _MD_RANDOMQUOTE_INVALID_SECURITY_TOKEN);
144
        }
145
146
        $input = new stdClass; // setup input array
147
148
        $input->id       = Request::getInt('id', RandomquoteConstants::DEFAULT_ID, 'POST');
149
        $input->quote    = Request::getText('quote', '', 'POST');
150
        $input->author   = Request::getText('author', '', 'POST');
151
        $input->item_tag = Request::getString('item_tag', '', 'POST');
152
153
        $verify_quote_status = Request::getInt('quote_status', RandomquoteConstants::STATUS_OFFLINE, 'POST');
154
        $input->quote_status = in_array($verify_quote_status, array(RandomquoteConstants::STATUS_ONLINE,
155
                                                                     RandomquoteConstants::STATUS_OFFLINE,
156
                                                                     RandomquoteConstants::STATUS_WAITING)) ? $verify_quote_status : RandomquoteConstants::STATUS_OFFLINE;
157
158
        if (!empty($input->id)) {
159
            $obj     = $quotesHandler->get($input->id);
160
            $add_msg = _AM_RANDOMQUOTE_FORM_UPDATE_OK;
161
        } else {
162
            $obj     = $quotesHandler->create();
163
            $add_msg = _AM_RANDOMQUOTE_FORM_ADD_OK;
164
        }
165
166
        $obj->setVars(array('quote'        => $input->quote,
167
                            'author'       => $input->author,
168
                            'quote_status' => $input->quote_status));
169
170
        if ($objId = $quotesHandler->insert($obj)) {
171
            //            $moduleHandler = xoops_gethandler('module');
172
            $tagModule = XoopsModule::getByDirname('tag');
173
            if (($tagModule instanceof XoopsModule) && $tagModule->isactive()) {
174
                $tagHandler = xoops_getModuleHandler('tag', 'tag');
175
                $tagHandler->updateByItem($input->item_tag, $objId, $thisDirname, 0);
176
            }
177
            redirect_header('main.php?op=list', RandomquoteConstants::REDIRECT_DELAY_MEDIUM, $add_msg);
178
        }
179
180
        echo $obj->getHtmlErrors();
181
        $form = $obj->getForm();
182
        $form->display();
183
        break;
184
185
    case 'edit_quote':
186
       $adminObject->displayNavigation(basename(__FILE__));
187
       $adminObject->addItemButton(_AM_RANDOMQUOTE_NEW_QUOTES, 'main.php?op=new_quote', 'add');
188
       $adminObject->addItemButton(_AM_RANDOMQUOTE_QUOTES_LIST, 'main.php?op=list', 'list');
189
       $adminObject->displayButton('left');
190
        $id = Request::getInt('id', RandomquoteConstants::DEFAULT_ID);
191
        if (empty($id)) {
192
            redirect_header($_SERVER['PHP_SELF'] . '?op=new_quote');
193
        }
194
        $obj  = $quotesHandler->get($id);
195
        $form = $obj->getForm();
196
        $form->display();
197
        break;
198
199
    case 'delete_quote':
200
        $delOk = Request::getInt('ok', RandomquoteConstants::CONFIRM_NOT_OK, 'POST');
201
        $id    = Request::getInt('id', RandomquoteConstants::DEFAULT_ID);
202
        if ($delOk) {
203
            // check to make sure this passes form submission security
204 View Code Duplication
            if ($GLOBALS['xoopsSecurity'] instanceof XoopsSecurity) {
205
                if (!$GLOBALS['xoopsSecurity']->check()) {
206
                    // failed xoops security check
207
                    redirect_header($_SERVER['PHP_SELF'], RandomquoteConstants::REDIRECT_DELAY_MEDIUM, $GLOBALS['xoopsSecurity']->getErrors(true));
208
                }
209
            } else {
210
                redirect_header('index.php', RandomquoteConstants::REDIRECT_DELAY_MEDIUM, _MD_RANDOMQUOTE_INVALID_SECURITY_TOKEN);
211
            }
212
            $obj = $quotesHandler->get($id);
213
            if ($obj instanceof RandomquoteQuotes) {
0 ignored issues
show
The class RandomquoteQuotes does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
214
                $itemId = $obj->getVar('id');
215
                if ($quotesHandler->delete($obj)) {
216
                    // now clear out items in tag module for this item
217
                    $moduleHandler = xoops_getHandler('module');
218
                    $tagModule     = XoopsModule::getByDirname('tag');
219
                    if (($tagModule instanceof XoopsModule) && $tagModule->isactive()) {
220
                        $tagHandler = xoops_getModuleHandler('tag', 'tag');
221
                        $tagHandler->updateByItem(array(), $itemId, $thisDirname);  //clear all tags for this item
222
                    }
223
                    redirect_header($_SERVER['PHP_SELF'], RandomquoteConstants::REDIRECT_DELAY_MEDIUM, _AM_RANDOMQUOTE_FORMDELOK);
224
                } else {
225
                    echo $obj->getHtmlErrors();
226
                }
227
            } else {
228
                redirect_header($_SERVER['PHP_SELF'], RandomquoteConstants::REDIRECT_DELAY_MEDIUM, _AM_RANDOMQUOTE_INVALID_QUOTE_ID);
229
            }
230
        } else {
231
            $obj = $quotesHandler->get($id);
232
            xoops_confirm(array('ok' => RandomquoteConstants::CONFIRM_OK, 'id' => $id, 'op' => 'delete_quote'), $_SERVER['REQUEST_URI'], sprintf(_AM_RANDOMQUOTE_FORMSUREDEL, $obj));
233
        }
234
        break;
235
}
236
require_once __DIR__ . '/admin_footer.php';
237