1
|
<?php
|
2
|
/*
|
3
|
* help.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8
|
* Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
|
9
|
* All rights reserved.
|
10
|
*
|
11
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
* you may not use this file except in compliance with the License.
|
13
|
* You may obtain a copy of the License at
|
14
|
*
|
15
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
*
|
17
|
* Unless required by applicable law or agreed to in writing, software
|
18
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
* See the License for the specific language governing permissions and
|
21
|
* limitations under the License.
|
22
|
*/
|
23
|
|
24
|
require_once("guiconfig.inc");
|
25
|
|
26
|
# Docs redirect base URL
|
27
|
$redirect_base = "https://docs.netgate.com/pfsense/help";
|
28
|
|
29
|
$pagename = "";
|
30
|
/* Check for parameter "page". */
|
31
|
if ($_REQUEST && isset($_REQUEST['page'])) {
|
32
|
$pagename = $_REQUEST['page'];
|
33
|
}
|
34
|
|
35
|
/* If "page" is not found, check referring URL */
|
36
|
if (empty($pagename)) {
|
37
|
/* Attempt to parse out filename */
|
38
|
$uri_split = "";
|
39
|
preg_match("/\/(.*)\?(.*)/", $_SERVER["HTTP_REFERER"], $uri_split);
|
40
|
|
41
|
/* If there was no match, there were no parameters, just grab the filename
|
42
|
Otherwise, use the matched filename from above. */
|
43
|
if (empty($uri_split[0])) {
|
44
|
$pagename = ltrim(parse_url($_SERVER["HTTP_REFERER"], PHP_URL_PATH), '/');
|
45
|
} else {
|
46
|
$pagename = $uri_split[1];
|
47
|
}
|
48
|
|
49
|
/* If the referrer was index.php then this was a redirect to help.php
|
50
|
because help.php was the first page the user has priv to.
|
51
|
In that case we do not want to redirect off to the dashboard help. */
|
52
|
if ($pagename == "index.php") {
|
53
|
$pagename = "";
|
54
|
}
|
55
|
|
56
|
/* If the filename is pkg_edit.php or wizard.php, reparse looking
|
57
|
for the .xml filename */
|
58
|
if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "wizard.php")) {
|
59
|
$param_split = explode('&', $uri_split[2]);
|
60
|
foreach ($param_split as $param) {
|
61
|
if (substr($param, 0, 4) == "xml=") {
|
62
|
$xmlfile = explode('=', $param);
|
63
|
$pagename = $xmlfile[1];
|
64
|
}
|
65
|
}
|
66
|
}
|
67
|
}
|
68
|
|
69
|
/* Using the derived page name, attempt to find in the URL mapping hash */
|
70
|
if (strlen($pagename) > 0) {
|
71
|
/* Clean up the page a little before attempting to use it in a redirect */
|
72
|
$pagename = urlencode(str_replace(array('%', ':', '..'), '', $pagename));
|
73
|
|
74
|
/* Redirect to help page. */
|
75
|
header("Location: {$redirect_base}/{$pagename}");
|
76
|
}
|
77
|
|
78
|
// No page name was determined, so show a message.
|
79
|
$pgtitle = array(gettext("Help"), gettext("About this Page"));
|
80
|
require_once("head.inc");
|
81
|
|
82
|
if (is_array($allowedpages) && str_replace('*', '', $allowedpages[0]) == "help.php") {
|
83
|
if (count($allowedpages) == 1) {
|
84
|
print_info_box(gettext("The Help page is the only page this user has privilege for."));
|
85
|
} else {
|
86
|
print_info_box(gettext("Displaying the Help page because it is the first page this user has privilege for."));
|
87
|
}
|
88
|
} else {
|
89
|
print_info_box(gettext("Help page accessed directly without any page parameter."));
|
90
|
}
|
91
|
|
92
|
include("foot.inc");
|
93
|
?>
|