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.

newsbythisauthor.php (2 issues)

Labels
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
/*
19
 * Display all the news by the author of a certain story
20
 *
21
 * This page is called from the page "article.php" and it will
22
 * show all the articles writen by an author. We use the module's
23
 * option named "restrictindex" to show or hide stories according
24
 * to users permissions and this page can only be called if the
25
 * module's option "newsbythisauthor" is set to "Yes"
26
 *
27
 * @package News
28
 * @author Xoops Modules Dev Team
29
 * @copyright   (c) XOOPS Project (https://xoops.org)
30
 *
31
 * Parameters received by this page :
32
 * @page_param  int     uid                     Id of the user you want to treat
33
 *
34
 * @page_title          "News by the same author" - Author's name - Module's name
35
 *
36
 * @template_name       news_by_this_author.html
37
 *
38
 * Template's variables :
39
 * @template_var    string  lang_page_title         contains "News by the same author"
40
 * @template_var    int     author_id               contains the user ID
41
 * @template_var    string  author_name             Name of the author (according to the user preferences (username or full name or nothing))
42
 * @template_var    string  author_name_with_link   Name of the author with a hyperlink pointing to userinfo.php (to see their "identity")
43
 * @template_var    int     articles_count          Total number of visibles articles (for the current user and according to the permissions)
44
 * @template_var    string  lang_date               Fixed string, "Date"
45
 * @template_var    string  lang_hits               Fixed string, 'Views'
46
 * @template_var    string  lang_title              Fixed string, 'Title'
47
 * @template_var    int     articles_count          Total number of articles by this author (permissions are used)
48
 * @template_var    boolean news_rating             News are rated ?
49
 * @template_var    string  lang_rating             Fixed text "Rating"
50
 * @template_var    array   topics                  Contains all the topics where the author have written some articles.
51
 *                                                  Structure :
52
 *                                                  topic_id    int     Topic's ID
53
 *                                                  topic_title string  Topic's title
54
 *                                                  topic_color string  Topic's color
55
 *                                                  topic_link  string  Link to see all the articles in this topic + topic's title
56
 *                                                  news        array   List of all the articles from this author for this topic
57
 *                                                      Structure :
58
 *                                                          int     id              Article's Id
59
 *                                                          string  hometext        The scoop
60
 *                                                          string  title           Article's title
61
 *                                                          int     hits            Counter of visits
62
 *                                                          string  created         Date of creation formated (according to user's prefs)
63
 *                                                          string  article_link    Link to see the article + article's title
64
 *                                                          string  published       Date of publication formated (according to user's prefs)
65
 *                                                          int     rating          Rating for this news
66
 */
67
68
use Xmf\Request;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Request. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
69
use XoopsModules\News;
70
use XoopsModules\News\NewsStory;
71
72
require_once \dirname(__DIR__, 2) . '/mainfile.php';
73
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
74
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php';
75
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.sfiles.php';
76
77
/** @var News\Helper $helper */
78
$helper = News\Helper::getInstance();
79
80
global $xoopsUser;
81
82
$helper = News\Helper::getInstance();
83
$helper->loadLanguage('modinfo');
84
85
$uid = Request::getInt('uid', 0, 'GET');
86
if (empty($uid)) {
87
    redirect_header('index.php', 2, _ERRORS);
88
}
89
90
if (!News\Utility::getModuleOption('newsbythisauthor')) {
91
    redirect_header('index.php', 2, _ERRORS);
92
}
93
94
$myts                                    = \MyTextSanitizer::getInstance();
95
$articles                                = new NewsStory();
96
$GLOBALS['xoopsOption']['template_main'] = 'news_by_this_author.tpl';
97
require_once XOOPS_ROOT_PATH . '/header.php';
98
99
$dateformat = News\Utility::getModuleOption('dateformat');
100
$infotips   = News\Utility::getModuleOption('infotips');
101
$thisuser   = new \XoopsUser($uid);
0 ignored issues
show
$uid of type integer is incompatible with the type array|null expected by parameter $id of XoopsUser::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

101
$thisuser   = new \XoopsUser(/** @scrutinizer ignore-type */ $uid);
Loading history...
102
103
switch ($helper->getConfig('displayname')) {
104
    case 1: // Username
105
        $authname = $thisuser->getVar('uname');
106
        break;
107
    case 2: // Display full name (if it is not empty)
108
        if ('' == xoops_trim($thisuser->getVar('name'))) {
109
            $authname = $thisuser->getVar('uname');
110
        } else {
111
            $authname = $thisuser->getVar('name');
112
        }
113
        break;
114
    case 3: // Nothing
115
        $authname = '';
116
        break;
117
}
118
$xoopsTpl->assign('lang_page_title', _MI_NEWSBYTHISAUTHOR . ' - ' . $authname);
119
$xoopsTpl->assign('lang_news_by_this_author', _MI_NEWSBYTHISAUTHOR);
120
$xoopsTpl->assign('author_id', $uid);
121
$xoopsTpl->assign('user_avatarurl', XOOPS_URL . '/uploads/' . $thisuser->getVar('user_avatar'));
122
$xoopsTpl->assign('author_name', $authname);
123
$xoopsTpl->assign('lang_date', _NW_DATE);
124
$xoopsTpl->assign('lang_hits', _NW_VIEWS);
125
$xoopsTpl->assign('lang_title', _NW_TITLE);
126
$xoopsTpl->assign('news_rating', News\Utility::getModuleOption('ratenews'));
127
$xoopsTpl->assign('lang_rating', _NW_RATING);
128
$xoopsTpl->assign('author_name_with_link', sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/userinfo.php?uid=' . $uid, $authname));
129
130
$oldtopic      = -1;
131
$oldtopictitle = '';
132
$oldtopiccolor = '';
133
$articlelist   = [];
134
$articlestpl   = [];
135
$articlelist   = $articles->getAllPublishedByAuthor($uid, $helper->getConfig('restrictindex'), false);
136
$articlescount = count($articlelist);
137
$xoopsTpl->assign('articles_count', $articlescount);
138
$count_articles = $count_reads = 0;
139
140
if ($articlescount > 0) {
141
    foreach ($articlelist as $article) {
142
        if ($oldtopic != $article['topicid']) {
143
            if (count($articlestpl) > 0) {
144
                $topic_link = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/index.php?storytopic=' . $oldtopic, $oldtopictitle);
145
                $xoopsTpl->append(
146
                    'topics',
147
                    [
148
                        'topic_id'             => $oldtopic,
149
                        'topic_count_articles' => sprintf(_AM_NEWS_TOTAL, $count_articles),
150
                        'topic_count_reads'    => $count_reads,
151
                        'topic_color'          => $oldtopiccolor,
152
                        'topic_title'          => $oldtopictitle,
153
                        'topic_link'           => $topic_link,
154
                        'news'                 => $articlestpl,
155
                    ]
156
                );
157
            }
158
            $oldtopic       = $article['topicid'];
159
            $oldtopictitle  = $article['topic_title'];
160
            $oldtopiccolor  = '#' . $myts->displayTarea($article['topic_color']);
161
            $articlestpl    = [];
162
            $count_articles = $count_reads = 0;
163
        }
164
        $htmltitle = '';
165
        if ($infotips > 0) {
166
            $htmltitle = ' title="' . News\Utility::makeInfotips($article['hometext']) . '"';
167
        }
168
        ++$count_articles;
169
        $count_reads   += $article['counter'];
170
        $articlestpl[] = [
171
            'id'           => $article['storyid'],
172
            'hometext'     => $article['hometext'],
173
            'title'        => $article['title'],
174
            'hits'         => $article['counter'],
175
            'created'      => formatTimestamp($article['created'], $dateformat),
176
            'article_link' => sprintf("<a href='%s'%s>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $article['storyid'], $htmltitle, $article['title']),
177
            'published'    => formatTimestamp($article['published'], $dateformat),
178
            'rating'       => $article['rating'],
179
        ];
180
    }
181
}
182
$topic_link = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/index.php?storytopic=' . $oldtopic, $oldtopictitle);
183
$xoopsTpl->append(
184
    'topics',
185
    [
186
        'topic_id'    => $oldtopic,
187
        'topic_title' => $oldtopictitle,
188
        'topic_link'  => $topic_link,
189
        'news'        => $articlestpl,
190
    ]
191
);
192
$xoopsTpl->assign('xoops_pagetitle', _MI_NEWSBYTHISAUTHOR . ' - ' . $authname . ' - ' . htmlspecialchars($xoopsModule->name(), ENT_QUOTES | ENT_HTML5));
193
$xoopsTpl->assign('advertisement', News\Utility::getModuleOption('advertisement'));
194
195
/**
196
 * Create the meta datas
197
 */
198
News\Utility::createMetaDatas();
199
200
$meta_description = _MI_NEWSBYTHISAUTHOR . ' - ' . $authname . ' - ' . $xoopsModule->name('s');
201
if (isset($xoTheme) && is_object($xoTheme)) {
202
    $xoTheme->addMeta('meta', 'description', $meta_description);
203
} else { // Compatibility for old Xoops versions
204
    $xoopsTpl->assign('xoops_meta_description', $meta_description);
205
}
206
207
require XOOPS_ROOT_PATH . '/include/comment_view.php';
208
require_once XOOPS_ROOT_PATH . '/footer.php';
209