1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Shows the page with the news record and - when available - the user |
5
|
|
|
* comments. |
6
|
|
|
* |
7
|
|
|
* |
8
|
|
|
* |
9
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public License, |
10
|
|
|
* v. 2.0. If a copy of the MPL was not distributed with this file, You can |
11
|
|
|
* obtain one at http://mozilla.org/MPL/2.0/. |
12
|
|
|
* |
13
|
|
|
* @package phpMyFAQ |
14
|
|
|
* |
15
|
|
|
* @author Thorsten Rinne <[email protected]> |
16
|
|
|
* @author Matteo Scaramuccia <[email protected]> |
17
|
|
|
* @copyright 2006-2019 phpMyFAQ Team |
18
|
|
|
* @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
19
|
|
|
* |
20
|
|
|
* @link https://www.phpmyfaq.de |
21
|
|
|
* @since 2006-07-23 |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
use phpMyFAQ\Captcha; |
25
|
|
|
use phpMyFAQ\Comment; |
26
|
|
|
use phpMyFAQ\Date; |
27
|
|
|
use phpMyFAQ\Filter; |
28
|
|
|
use phpMyFAQ\Glossary; |
29
|
|
|
use phpMyFAQ\Helper\CaptchaHelper; |
30
|
|
|
use phpMyFAQ\Link; |
31
|
|
|
use phpMyFAQ\News; |
32
|
|
|
|
33
|
|
View Code Duplication |
if (!defined('IS_VALID_PHPMYFAQ')) { |
34
|
|
|
$protocol = 'http'; |
35
|
|
|
if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) === 'ON') { |
36
|
|
|
$protocol = 'https'; |
37
|
|
|
} |
38
|
|
|
header('Location: '.$protocol.'://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])); |
39
|
|
|
exit(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$captcha = new Captcha($faqConfig); |
43
|
|
|
$comment = new Comment($faqConfig); |
44
|
|
|
|
45
|
|
|
$captcha->setSessionId($sids); |
46
|
|
|
if (!is_null($showCaptcha)) { |
47
|
|
|
$captcha->showCaptchaImg(); |
48
|
|
|
exit; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$oNews = new News($faqConfig); |
52
|
|
|
$newsId = Filter::filterInput(INPUT_GET, 'newsid', FILTER_VALIDATE_INT); |
53
|
|
|
|
54
|
|
|
if (is_null($newsId)) { |
55
|
|
|
header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])); |
56
|
|
|
exit(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
try { |
60
|
|
|
$faqSession->userTracking('news_view', $newsId); |
61
|
|
|
} catch (Exception $e) { |
62
|
|
|
// @todo handle the exception |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
// Define the header of the page |
66
|
|
|
$newsMainHeader = $faqConfig->get('main.titleFAQ').$PMF_LANG['msgNews']; |
67
|
|
|
if ($faqConfig->get('main.enableRssFeeds')) { |
68
|
|
|
$newsFeed = ' <a href="feed/news/rss.php" target="_blank"><i class="fas fa-rss-square"></i></a>'; |
69
|
|
|
} else { |
70
|
|
|
$newsFeed = ''; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
// Get all data from the news record |
74
|
|
|
$news = $oNews->getNewsEntry($newsId); |
75
|
|
|
|
76
|
|
|
$newsContent = $news['content']; |
77
|
|
|
$newsHeader = $news['header']; |
78
|
|
|
|
79
|
|
|
// Add Glossary entries |
80
|
|
|
$oGlossary = new Glossary($faqConfig); |
81
|
|
|
$newsContent = $oGlossary->insertItemsIntoContent($newsContent); |
82
|
|
|
$newsHeader = $oGlossary->insertItemsIntoContent($newsHeader); |
83
|
|
|
|
84
|
|
|
// Add information link if existing |
85
|
|
View Code Duplication |
if (strlen($news['link']) > 0) { |
86
|
|
|
$newsContent .= sprintf('</p><p>%s<a href="%s" target="%s">%s</a>', |
87
|
|
|
$PMF_LANG['msgInfo'], |
88
|
|
|
$news['link'], |
89
|
|
|
$news['target'], |
90
|
|
|
$news['linkTitle']); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
// Show link to edit the news? |
94
|
|
|
$editThisEntry = ''; |
95
|
|
|
if ($user->perm->checkRight($user->getUserId(), 'editnews')) { |
96
|
|
|
$editThisEntry = sprintf( |
97
|
|
|
'<a href="%sadmin/index.php?action=news&do=edit&id=%d">%s</a>', |
98
|
|
|
Link::getSystemRelativeUri('index.php'), |
99
|
|
|
$newsId, |
100
|
|
|
$PMF_LANG['ad_menu_news_edit']); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
// Is the news item expired? |
104
|
|
|
$expired = (date('YmdHis') > $news['dateEnd']); |
105
|
|
|
|
106
|
|
|
// Does the user have the right to add a comment? |
107
|
|
|
if ((-1 === $user->getUserId() && !$faqConfig->get('records.allowCommentsForGuests')) || |
108
|
|
|
(!$news['active']) || (!$news['allowComments']) || $expired) { |
109
|
|
|
$commentMessage = $PMF_LANG['msgWriteNoComment']; |
110
|
|
|
} else { |
111
|
|
|
$commentMessage = sprintf('<a href="#" class="show-comment-form">%s</a>', $PMF_LANG['newsWriteComment']); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
// date of news entry |
115
|
|
|
if ($news['active'] && (!$expired)) { |
116
|
|
|
$date = new Date($faqConfig); |
117
|
|
|
$newsDate = sprintf('%s<span id="newsLastUpd">%s</span>', |
118
|
|
|
$PMF_LANG['msgLastUpdateArticle'], |
119
|
|
|
$date->format($news['date']) |
120
|
|
|
); |
121
|
|
|
} else { |
122
|
|
|
$newsDate = ''; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
$captchaHelper = new CaptchaHelper($faqConfig); |
126
|
|
|
|
127
|
|
|
$template->parse( |
128
|
|
|
'writeContent', |
129
|
|
|
array( |
130
|
|
|
'writeNewsHeader' => $newsMainHeader, |
131
|
|
|
'writeNewsRSS' => $newsFeed, |
132
|
|
|
'writeHeader' => $newsHeader, |
133
|
|
|
'writeContent' => $newsContent, |
134
|
|
|
'writeDateMsg' => $newsDate, |
135
|
|
|
'msgAboutThisNews' => $PMF_LANG['msgAboutThisNews'], |
136
|
|
|
'writeAuthor' => ($news['active'] && (!$expired)) ? $PMF_LANG['msgAuthor'].': '.$news['authorName'] : '', |
137
|
|
|
'editThisEntry' => $editThisEntry, |
138
|
|
|
'writeCommentMsg' => $commentMessage, |
139
|
|
|
'msgWriteComment' => $PMF_LANG['newsWriteComment'], |
140
|
|
|
'newsId' => $newsId, |
141
|
|
|
'newsLang' => $news['lang'], |
142
|
|
|
'msgCommentHeader' => $PMF_LANG['msgCommentHeader'], |
143
|
|
|
'msgNewContentName' => $PMF_LANG['msgNewContentName'], |
144
|
|
|
'msgNewContentMail' => $PMF_LANG['msgNewContentMail'], |
145
|
|
|
'defaultContentMail' => ($user instanceof CurrentUser) ? $user->getUserData('email') : '', |
|
|
|
|
146
|
|
|
'defaultContentName' => ($user instanceof CurrentUser) ? $user->getUserData('display_name') : '', |
|
|
|
|
147
|
|
|
'msgYourComment' => $PMF_LANG['msgYourComment'], |
148
|
|
|
'msgNewContentSubmit' => $PMF_LANG['msgNewContentSubmit'], |
149
|
|
|
'captchaFieldset' => $captchaHelper->renderCaptcha($captcha, 'writecomment', $PMF_LANG['msgCaptcha'], $auth), |
150
|
|
|
'writeComments' => $comment->getComments($newsId, Comment::COMMENT_TYPE_NEWS), |
151
|
|
|
) |
152
|
|
|
); |
153
|
|
|
|
154
|
|
|
$template->parseBlock( |
155
|
|
|
'index', |
156
|
|
|
'breadcrumb', |
157
|
|
|
[ |
158
|
|
|
'breadcrumbHeadline' => $newsMainHeader |
159
|
|
|
] |
160
|
|
|
); |
161
|
|
|
|
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 thecomposer.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
orrequire-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 you have not tested against this specific condition, such errors might go unnoticed.