Issues (384)

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.

blocks/news_archives.php (9 issues)

1
<?php declare(strict_types=1);
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright      {@link https://xoops.org/ XOOPS Project}
14
 * @license        {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @author         XOOPS Development Team
16
 */
17
18
use XoopsModules\News;
19
use XoopsModules\News\Helper;
20
use XoopsModules\News\NewsStory;
21
22
// require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
23
24
/**
25
 * Display archives
26
 *
27
 * @param array $options :
28
 *                       0 = sort order (0=older first, 1=newer first)
29
 *                       1 = Starting date, year
30
 *                       2 = Starting date, month
31
 *                       3 = Ending date, year
32
 *                       4 = Ending date, month
33
 *                       5 = until today ?
34
 *
35
 * @return array|string
36
 */
37
function b_news_archives_show($options)
38
{
39
    global $xoopsDB, $xoopsConfig;
40
    // require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
41
    require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/calendar.php';
42
43
    /** @var Helper $helper */
44
    if (!class_exists(Helper::class)) {
45
        //            throw new \RuntimeException('Unable to create the $helper directory');
46
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type array|string.
Loading history...
47
    }
48
49
    $helper = Helper::getInstance();
50
    $helper->loadLanguage('main');
51
52
    $months_arr    = [
53
        1  => _CAL_JANUARY,
54
        2  => _CAL_FEBRUARY,
55
        3  => _CAL_MARCH,
56
        4  => _CAL_APRIL,
57
        5  => _CAL_MAY,
58
        6  => _CAL_JUNE,
59
        7  => _CAL_JULY,
60
        8  => _CAL_AUGUST,
61
        9  => _CAL_SEPTEMBER,
62
        10 => _CAL_OCTOBER,
63
        11 => _CAL_NOVEMBER,
64
        12 => _CAL_DECEMBER,
65
    ];
66
    $block         = [];
67
    $sort_order    = 0 == $options[0] ? 'ASC' : 'DESC';
68
    $starting_date = mktime(0, 0, 0, (int)$options[2], 1, (int)$options[1]);
69
    if (1 != (int)$options[5]) {
70
        $ending_date = mktime(23, 59, 59, (int)$options[4], 28, (int)$options[3]);
71
    } else {
72
        $ending_date = time();
73
    }
74
    $sql    = "SELECT DISTINCT(FROM_UNIXTIME(published,'%Y-%m')) AS published FROM " . $xoopsDB->prefix('news_stories') . ' WHERE published>=' . $starting_date . ' AND published<=' . $ending_date . ' ORDER BY published ' . $sort_order;
75
    $result = $xoopsDB->query($sql);
76
    if (!$result) {
77
        return '';
78
    }
79
    while (false !== ($myrow = $xoopsDB->fetchArray($result))) {
80
        $year                = (int)mb_substr($myrow['published'], 0, 4);
81
        $month               = (int)mb_substr($myrow['published'], 5, 2);
82
        $formated_month      = $months_arr[$month];
83
        $block['archives'][] = ['month' => $month, 'year' => $year, 'formated_month' => $formated_month];
84
    }
85
86
    return $block;
87
}
88
89
/**
90
 * @param $options
91
 *
92
 * @return string
93
 */
94
function b_news_archives_edit($options)
95
{
96
    global $xoopsDB;
97
    $syear    = $smonth = $eyear = $emonth = $older = $recent = 0;
0 ignored issues
show
The assignment to $eyear is dead and can be removed.
Loading history...
The assignment to $syear is dead and can be removed.
Loading history...
The assignment to $smonth is dead and can be removed.
Loading history...
The assignment to $emonth is dead and can be removed.
Loading history...
98
    $selsyear = $selsmonth = $seleyear = $selemonth = 0;
0 ignored issues
show
The assignment to $seleyear is dead and can be removed.
Loading history...
The assignment to $selsyear is dead and can be removed.
Loading history...
The assignment to $selemonth is dead and can be removed.
Loading history...
The assignment to $selsmonth is dead and can be removed.
Loading history...
99
    $form     = '';
100
101
    $selsyear  = $options[1];
102
    $selsmonth = $options[2];
103
    $seleyear  = $options[3];
104
    $selemonth = $options[4];
105
106
    $tmpstory = new NewsStory();
107
    $tmpstory->getOlderRecentNews($older, $recent); // We are searching for the module's older and more recent article's date
108
109
    // Min and max value for the two dates selectors
110
    // We are going to use the older news for the starting date
111
    $syear  = date('Y', $older);
112
    $smonth = date('n', $older);
113
    $eyear  = date('Y', $recent);
114
    $emonth = date('n', $recent);
115
    // Verify parameters
116
    if (0 == $selsyear && 0 == $selsmonth) {
117
        $selsyear  = $syear;
118
        $selsmonth = $smonth;
119
    }
120
    if (0 == $seleyear && 0 == $selemonth) {
121
        $seleyear  = $eyear;
122
        $selemonth = $emonth;
123
    }
124
125
    // Sort order *************************************************************
126
    // (0=older first, 1=newer first)
127
    $form .= '<b>' . _MB_NEWS_ORDER . "</b>&nbsp;<select name='options[]'>";
128
    $form .= "<option value='0'";
129
    if (0 == $options[0]) {
130
        $form .= ' selected';
131
    }
132
    $form .= '>' . _MB_NEWS_OLDER_FIRST . "</option>\n";
133
    $form .= "<option value='1'";
134
    if (1 == $options[0]) {
135
        $form .= ' selected';
136
    }
137
    $form .= '>' . _MB_NEWS_RECENT_FIRST . '</option>';
138
    $form .= "</select>\n";
139
140
    // Starting and ending dates **********************************************
141
    $form .= '<br><br><b>' . _MB_NEWS_STARTING_DATE . '</b><br>';
142
    $form .= _MB_NEWS_CAL_YEAR . "&nbsp;<select name='options[]'>";
143
    for ($i = $syear; $i <= $eyear; ++$i) {
144
        $selected = ($i == $selsyear) ? 'selected' : '';
145
        $form     .= "<option value='" . $i . "'" . $selected . '>' . $i . '</option>';
146
    }
147
    $form .= '</select>&nbsp;' . _MB_NEWS_CAL_MONTH . "&nbsp;<select name='options[]'>";
148
    for ($i = 1; $i <= 12; ++$i) {
149
        $selected = ($i == $selsmonth) ? 'selected' : '';
150
        $form     .= "<option value='" . $i . "'" . $selected . '>' . $i . '</option>';
151
    }
152
    $form .= '</select>';
153
154
    $form .= '<br><br><b>' . _MB_NEWS_ENDING_DATE . '</b><br>';
155
    $form .= _MB_NEWS_CAL_YEAR . "&nbsp;<select name='options[]'>";
156
    for ($i = $syear; $i <= $eyear; ++$i) {
157
        $selected = ($i == $seleyear) ? 'selected' : '';
158
        $form     .= "<option value='" . $i . "'" . $selected . '>' . $i . '</option>';
159
    }
160
    $form .= '</select>&nbsp;' . _MB_NEWS_CAL_MONTH . "&nbsp;<select name='options[]'>";
161
    for ($i = 1; $i <= 12; ++$i) {
162
        $selected = ($i == $selemonth) ? 'selected' : '';
163
        $form     .= "<option value='" . $i . "'" . $selected . '>' . $i . '</option>';
164
    }
165
    $form .= '</select>';
166
167
    // Or until today *********************************************************
168
    $form    .= '<br>';
169
    $checked = 1 == $options[5] ? ' checked' : '';
170
    $form    .= "<input type='checkbox' value='1' name='options[]'" . $checked . '>';
171
    $form    .= ' <b>' . _MB_NEWS_UNTIL_TODAY . '</b>';
172
173
    return $form;
174
}
175
176
/**
177
 * @param $options
178
 */
179
function b_news_archives_onthefly($options): void
180
{
181
    $options = explode('|', $options);
182
    $block   = b_news_archives_show($options);
183
184
    $tpl = new \XoopsTpl();
185
    $tpl->assign('block', $block);
186
    $tpl->display('db:news_block_archives.tpl');
187
}
188