1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PDF export. |
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
|
|
|
* |
14
|
|
|
* @author Thorsten Rinne <[email protected]> |
15
|
|
|
* @author Peter Beauvain <[email protected]> |
16
|
|
|
* @author Olivier Plathey <[email protected]> |
17
|
|
|
* @author Krzysztof Kruszynski <[email protected]> |
18
|
|
|
* @author Matteo Scaramuccia <[email protected]> |
19
|
|
|
* @copyright 2003-2019 phpMyFAQ Team |
20
|
|
|
* @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
21
|
|
|
* |
22
|
|
|
* @link https://www.phpmyfaq.de |
23
|
|
|
* @since 2003-02-12 |
24
|
|
|
*/ |
25
|
|
|
define('IS_VALID_PHPMYFAQ', null); |
26
|
|
|
|
27
|
|
|
// |
28
|
|
|
// Bootstrapping |
29
|
|
|
// |
30
|
|
|
require 'src/Bootstrap.php'; |
31
|
|
|
|
32
|
|
|
// get language (default: english) |
33
|
|
|
$Language = new phpMyFAQ\Language($faqConfig); |
34
|
|
|
$LANGCODE = $Language->setLanguage($faqConfig->get('main.languageDetection'), $faqConfig->get('main.language')); |
35
|
|
|
$faqConfig->setLanguage($Language); |
36
|
|
|
|
37
|
|
|
// Found an article language? |
38
|
|
|
$lang = phpMyFAQ\Filter::filterInput(INPUT_POST, 'artlang', FILTER_SANITIZE_STRING); |
39
|
|
View Code Duplication |
if (is_null($lang) && !Language::isASupportedLanguage($lang)) { |
40
|
|
|
$lang = phpMyFAQ\Filter::filterInput(INPUT_GET, 'artlang', FILTER_SANITIZE_STRING); |
41
|
|
|
if (is_null($lang) && !Language::isASupportedLanguage($lang)) { |
42
|
|
|
$lang = $LANGCODE; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if (isset($lang) && Language::isASupportedLanguage($lang)) { |
47
|
|
|
require_once 'lang/language_'.$lang.'.php'; |
48
|
|
|
} else { |
49
|
|
|
$lang = 'en'; |
50
|
|
|
require_once 'lang/language_en.php'; |
51
|
|
|
} |
52
|
|
|
// |
53
|
|
|
// Initializing static string wrapper |
54
|
|
|
// |
55
|
|
|
Strings::init($LANGCODE); |
56
|
|
|
|
57
|
|
|
// authenticate with session information |
58
|
|
|
$user = CurrentUser::getFromCookie($faqConfig); |
59
|
|
|
if (!$user instanceof CurrentUser) { |
|
|
|
|
60
|
|
|
$user = CurrentUser::getFromSession($faqConfig); |
61
|
|
|
} |
62
|
|
|
if ($user instanceof CurrentUser) { |
|
|
|
|
63
|
|
|
$auth = true; |
64
|
|
|
} else { |
65
|
|
|
$user = null; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
// Get current user and group id - default: -1 |
69
|
|
View Code Duplication |
if (!is_null($user) && $user instanceof CurrentUser) { |
|
|
|
|
70
|
|
|
$current_user = $user->getUserId(); |
71
|
|
|
if ($user->perm instanceof Medium) { |
|
|
|
|
72
|
|
|
$current_groups = $user->perm->getUserGroups($current_user); |
73
|
|
|
} else { |
74
|
|
|
$current_groups = array(-1); |
75
|
|
|
} |
76
|
|
|
if (0 == count($current_groups)) { |
77
|
|
|
$current_groups = array(-1); |
78
|
|
|
} |
79
|
|
|
} else { |
80
|
|
|
$current_user = -1; |
81
|
|
|
$current_groups = array(-1); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$currentCategory = phpMyFAQ\Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT); |
85
|
|
|
$id = phpMyFAQ\Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT); |
86
|
|
|
$getAll = phpMyFAQ\Filter::filterInput(INPUT_GET, 'getAll', FILTER_VALIDATE_BOOLEAN, false); |
87
|
|
|
|
88
|
|
|
$faq = new phpMyFAQ\Faq($faqConfig); |
89
|
|
|
$faq->setUser($current_user); |
90
|
|
|
$faq->setGroups($current_groups); |
91
|
|
|
|
92
|
|
|
$category = new phpMyFAQ\Category($faqConfig, $current_groups, true); |
93
|
|
|
$category->setUser($current_user); |
94
|
|
|
|
95
|
|
|
$pdf = new phpMyFAQ\Export_Pdf($faq, $category, $faqConfig); |
96
|
|
|
$http = new phpMyFAQ\Helper_Http(); |
97
|
|
|
|
98
|
|
|
if (true === $getAll) { |
99
|
|
|
$category->buildTree(); |
100
|
|
|
} |
101
|
|
|
$tags = new phpMyFAQ\Tags($faqConfig); |
102
|
|
|
|
103
|
|
|
session_cache_limiter('private'); |
104
|
|
|
|
105
|
|
|
$headers = array( |
106
|
|
|
'Pragma: public', |
107
|
|
|
'Expires: 0', |
108
|
|
|
'Cache-Control: must-revalidate, post-check=0, pre-check=0', |
109
|
|
|
); |
110
|
|
|
|
111
|
|
|
if (true === $getAll && $user->perm->checkRight($user->getUserId(), 'export')) { |
112
|
|
|
$filename = 'FAQs.pdf'; |
113
|
|
|
$pdfFile = $pdf->generate(0, true, $lang); |
114
|
|
|
} else { |
115
|
|
|
if (is_null($currentCategory) || is_null($id)) { |
116
|
|
|
$http->redirect($faqConfig->getDefaultUrl()); |
117
|
|
|
exit(); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
$faq->getRecord($id); |
121
|
|
|
$faq->faqRecord['category_id'] = $currentCategory; |
122
|
|
|
|
123
|
|
|
$filename = 'FAQ-'.$id.'-'.$lang.'.pdf'; |
124
|
|
|
$pdfFile = $pdf->generateFile($faq->faqRecord, $filename); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
if (preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT'])) { |
128
|
|
|
$headers[] = 'Content-type: application/pdf'; |
129
|
|
|
$headers[] = 'Content-Transfer-Encoding: binary'; |
130
|
|
|
$headers[] = 'Content-Disposition: attachment; filename='.$filename; |
131
|
|
|
} else { |
132
|
|
|
$headers[] = 'Content-Type: application/pdf'; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
$http->sendWithHeaders($pdfFile, $headers); |
136
|
|
|
|
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.