This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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
|
|||||
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
![]() |
|||||
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 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/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 beforeOtherDir/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: