Issues (267)

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.

class/Common/LetterChoice.php (2 issues)

1
<?php
2
3
namespace XoopsModules\Xoopstube\Common;
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
 * LetterChoice class
17
 *
18
 * @copyright   XOOPS Project (https://xoops.org)
19
 * @license     https://www.fsf.org/copyleft/gpl.html GNU public license
20
 * @author      lucio <[email protected]>
21
 * @package     xoopstube
22
 * @since       1.00
23
 *
24
 * Example:
25
 * $choicebyletter = new LetterChoice($objHandler, null, null, range('a', 'z'), 'letter');
26
 * echo $choicebyletter->render();
27
 */
28
29
use XoopsModules\Xoopstube\{
30
    Helper
31
};
32
/** @var Helper $helper */
33
34
// require_once \dirname(__DIR__, 2) . '/include/common.php';
35
36
/**
37
 * Class LetterChoice
38
 */
39
class LetterChoice
40
{
41
    /**
42
     * @access public
43
     */
44
    public $helper;
45
    /**
46
     * *#@+
47
     *
48
     * @access private
49
     */
50
    private $objHandler;
51
    private $criteria;
52
    private $field_name;
53
    private $alphabet;
54
    private $arg_name;
55
    private $url;
56
    private $extra;
57
    private $caseSensitive;
58
59
//    /**
60
//     * *#@-
61
//     * @param mixed      $objHandler
62
//     * @param null|mixed $criteria
63
//     * @param null|mixed $field_name
64
//     * @param mixed      $arg_name
65
//     * @param null|mixed $url
66
//     * @param mixed      $extra_arg
67
//     * @param mixed      $caseSensitive
68
//     */
69
70
    /**
71
     * Constructor
72
     *
73
     * @param \XoopsPersistableObjectHandler $objHandler {@link XoopsPersistableObjectHandler}
74
     * @param \CriteriaElement               $criteria   {@link CriteriaElement}
75
     * @param string                         $field_name search by field
76
     * @param array                          $alphabet   array of alphabet letters
77
     * @param string                         $arg_name   item on the current page
78
     * @param string                         $url
79
     * @param string                         $extra_arg  Additional arguments to pass in the URL
80
     * @param bool                           $caseSensitive
81
     */
82
    public function __construct(
83
        $objHandler,
84
        $criteria = null,
85
        $field_name = null,
86
        array $alphabet = [],
87
        $arg_name = 'letter',
88
        $url = null,
89
        $extra_arg = '',
90
        $caseSensitive = false
91
    ) {
92
        $this->helper     = Helper::getInstance();
93
        $this->objHandler = $objHandler;
94
        $this->criteria   = $criteria ?? new \CriteriaCompo();
95
        $this->field_name = $field_name ?? $this->objHandler->identifierName;
96
        //        $this->alphabet   = (count($alphabet) > 0) ? $alphabet : range('a', 'z'); // is there a way to get locale alphabet?
97
        //        $this->alphabet       = getLocalAlphabet();
98
        $this->alphabet = require \dirname(__DIR__, 2) . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/alphabet.php';
99
        $this->arg_name = $arg_name;
100
        $this->url      = $url ?? $_SERVER['SCRIPT_NAME'];
101
        if ('' !== $extra_arg && ('&amp;' !== mb_substr($extra_arg, -5) || '&' !== mb_substr($extra_arg, -1))) {
102
            $this->extra = '&amp;' . $extra_arg;
103
        }
104
        $this->caseSensitive = $caseSensitive;
105
    }
106
107
    /**
108
     * Create choice by letter
109
     *
110
     * @param null $alphaCount
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $alphaCount is correct as it would always require null to be passed?
Loading history...
111
     * @param null $howmanyother
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $howmanyother is correct as it would always require null to be passed?
Loading history...
112
     * @return string
113
     */
114
    public function render($alphaCount = null, $howmanyother = null)
115
    {
116
        $moduleDirName      = \basename(\dirname(__DIR__, 2));
117
        $moduleDirNameUpper = mb_strtoupper($moduleDirName);
118
        \xoops_loadLanguage('common', $moduleDirName);
119
        \xoops_loadLanguage('alphabet', $moduleDirName);
120
        $all   = \constant('CO_' . $moduleDirNameUpper . '_ALL');
121
        $other = \constant('CO_' . $moduleDirNameUpper . '_OTHER');
122
123
        $ret = '';
124
125
        if (!$this->caseSensitive) {
126
            $this->criteria->setGroupBy('UPPER(LEFT(' . $this->field_name . ',1))');
127
        } else {
128
            $this->criteria->setGroupBy('LEFT(' . $this->field_name . ',1)');
129
        }
130
        $countsByLetters = $this->objHandler->getCounts($this->criteria);
131
        // fill alphabet array
132
        $alphabetArray = [];
133
        $letter_array  = [];
134
135
        $letter                 = 'All';
136
        $letter_array['letter'] = $all;
137
        $letter_array['count']  = $alphaCount;
138
        $letter_array['url']    = $this->url;
139
        $alphabetArray[$letter] = $letter_array;
140
141
        foreach ($this->alphabet as $letter) {
142
//            $letter_array = [];
143
            if (!$this->caseSensitive) {
144
                if (isset($countsByLetters[mb_strtoupper($letter)])) {
145
                    $letter_array['letter'] = $letter;
146
                    $letter_array['count']  = $countsByLetters[mb_strtoupper($letter)];
147
                    $letter_array['url']    = $this->url . '?' . $this->arg_name . '=' . $letter . $this->extra;
148
                } else {
149
                    $letter_array['letter'] = $letter;
150
                    $letter_array['count']  = 0;
151
                    $letter_array['url']    = '';
152
                }
153
            } elseif (isset($countsByLetters[$letter])) {
154
                $letter_array['letter'] = $letter;
155
                $letter_array['count']  = $countsByLetters[$letter];
156
                $letter_array['url']    = $this->url . '?' . $this->arg_name . '=' . $letter . $this->extra;
157
            } else {
158
                $letter_array['letter'] = $letter;
159
                $letter_array['count']  = 0;
160
                $letter_array['url']    = '';
161
            }
162
            $alphabetArray[$letter] = $letter_array;
163
            unset($letter_array);
164
        }
165
166
        $letter_array['letter'] = $other;
167
        $letter_array['count']  = $howmanyother;
168
        $letter_array['url']    = $this->url . '?init=Other';
169
        $alphabetArray[$letter] = $letter_array;
170
171
        // render output
172
        if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) {
173
            require_once $GLOBALS['xoops']->path('/class/theme.php');
174
            $GLOBALS['xoTheme'] = new \xos_opal_Theme();
175
        }
176
        require_once $GLOBALS['xoops']->path('/class/template.php');
177
        $choiceByLetterTpl          = new \XoopsTpl();
178
        $choiceByLetterTpl->caching = 0; // Disable cache
179
        $choiceByLetterTpl->assign('alphabet', $alphabetArray);
180
        $ret .= $choiceByLetterTpl->fetch("db:{$this->helper->getDirname()}_letterschoice.tpl");
181
        unset($choiceByLetterTpl);
182
183
        return $ret;
184
    }
185
}
186