1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Page for adding new questions. |
5
|
|
|
* |
6
|
|
|
* |
7
|
|
|
* |
8
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public License, |
9
|
|
|
* v. 2.0. If a copy of the MPL was not distributed with this file, You can |
10
|
|
|
* obtain one at http://mozilla.org/MPL/2.0/. |
11
|
|
|
* |
12
|
|
|
* @package phpMyFAQ |
13
|
|
|
* @author Thorsten Rinne <[email protected]> |
14
|
|
|
* @copyright 2002-2019 phpMyFAQ Team |
15
|
|
|
* @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
16
|
|
|
* @link https://www.phpmyfaq.de |
17
|
|
|
* @since 2002-09-17 |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
use phpMyFAQ\Captcha; |
21
|
|
|
use phpMyFAQ\Filter; |
22
|
|
|
use phpMyFAQ\Helper\CategoryHelper as HelperCategory; |
23
|
|
|
use phpMyFAQ\Helper\CaptchaHelper; |
24
|
|
|
|
25
|
|
View Code Duplication |
if (!defined('IS_VALID_PHPMYFAQ')) { |
26
|
|
|
$protocol = 'http'; |
27
|
|
|
if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) === 'ON') { |
28
|
|
|
$protocol = 'https'; |
29
|
|
|
} |
30
|
|
|
header('Location: '.$protocol.'://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])); |
31
|
|
|
exit(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
// Check user permissions |
35
|
|
View Code Duplication |
if ((-1 === $user->getUserId() && !$faqConfig->get('records.allowQuestionsForGuests'))) { |
36
|
|
|
header('Location:'.$faqSystem->getSystemUri($faqConfig).'?action=login'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$captcha = new Captcha($faqConfig); |
40
|
|
|
$captcha->setSessionId($sids); |
41
|
|
|
|
42
|
|
|
if (!is_null($showCaptcha)) { |
43
|
|
|
$captcha->showCaptchaImg(); |
44
|
|
|
exit; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
try { |
48
|
|
|
$faqSession->userTracking('ask_question', 0); |
49
|
|
|
} catch (Exception $e) { |
50
|
|
|
// @todo handle the exception |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$category->buildTree(); |
54
|
|
|
|
55
|
|
|
$categoryId = Filter::filterInput(INPUT_GET, 'category_id', FILTER_VALIDATE_INT, 0); |
56
|
|
|
|
57
|
|
|
$categoryHelper = new HelperCategory(); |
58
|
|
|
$categoryHelper->setCategory($category); |
59
|
|
|
|
60
|
|
|
$captchaHelper = new CaptchaHelper($faqConfig); |
61
|
|
|
|
62
|
|
|
$template->parse( |
63
|
|
|
'writeContent', |
64
|
|
|
[ |
65
|
|
|
'msgQuestion' => $PMF_LANG['msgQuestion'], |
66
|
|
|
'msgNewQuestion' => $PMF_LANG['msgNewQuestion'], |
67
|
|
|
'msgMatchingQuestions' => $PMF_LANG['msgMatchingQuestions'], |
68
|
|
|
'msgFinishSubmission' => $PMF_LANG['msgFinishSubmission'], |
69
|
|
|
'lang' => $Language->getLanguage(), |
70
|
|
|
'msgNewContentName' => $PMF_LANG['msgNewContentName'], |
71
|
|
|
'msgNewContentMail' => $PMF_LANG['msgNewContentMail'], |
72
|
|
|
'defaultContentMail' => ($user instanceof CurrentUser) ? $user->getUserData('email') : '', |
|
|
|
|
73
|
|
|
'defaultContentName' => ($user instanceof CurrentUser) ? $user->getUserData('display_name') : '', |
|
|
|
|
74
|
|
|
'msgAskCategory' => $PMF_LANG['msgAskCategory'], |
75
|
|
|
'printCategoryOptions' => $categoryHelper->renderOptions($categoryId), |
76
|
|
|
'msgAskYourQuestion' => $PMF_LANG['msgAskYourQuestion'], |
77
|
|
|
'captchaFieldset' => $captchaHelper->renderCaptcha($captcha, 'ask', $PMF_LANG['msgCaptcha'], $auth), |
78
|
|
|
'msgNewContentSubmit' => $PMF_LANG['msgNewContentSubmit'], |
79
|
|
|
] |
80
|
|
|
); |
81
|
|
|
|
82
|
|
|
$template->parseBlock( |
83
|
|
|
'index', |
84
|
|
|
'breadcrumb', |
85
|
|
|
[ |
86
|
|
|
'breadcrumbHeadline' => $PMF_LANG['msgQuestion'] |
87
|
|
|
] |
88
|
|
|
); |
89
|
|
|
|
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.