1 |
5262b29a
|
jim-p
|
<?php
|
2 |
919d91f9
|
Phil Davis
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* help.php
|
4 |
fd9ebcd5
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
8f2f85c3
|
Luiz Otavio O Souza
|
* Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
|
9 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
10 |
fd9ebcd5
|
Stephen Beaver
|
*
|
11 |
b12ea3fb
|
Renato Botelho
|
* 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 |
fd9ebcd5
|
Stephen Beaver
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16 |
fd9ebcd5
|
Stephen Beaver
|
*
|
17 |
b12ea3fb
|
Renato Botelho
|
* 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 |
5262b29a
|
jim-p
|
*/
|
23 |
919d91f9
|
Phil Davis
|
|
24 |
bb7469ca
|
Ermal
|
require_once("guiconfig.inc");
|
25 |
|
|
|
26 |
0f2df9bb
|
jim-p
|
# Docs redirect base URL
|
27 |
|
|
$redirect_base = "https://docs.netgate.com/pfsense/help";
|
28 |
5262b29a
|
jim-p
|
|
29 |
|
|
$pagename = "";
|
30 |
|
|
/* Check for parameter "page". */
|
31 |
cbb82e6b
|
Steve Beaver
|
if ($_REQUEST && isset($_REQUEST['page'])) {
|
32 |
|
|
$pagename = $_REQUEST['page'];
|
33 |
5262b29a
|
jim-p
|
}
|
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 |
ae5c8d0e
|
Warren Baker
|
$pagename = ltrim(parse_url($_SERVER["HTTP_REFERER"], PHP_URL_PATH), '/');
|
45 |
5262b29a
|
jim-p
|
} else {
|
46 |
|
|
$pagename = $uri_split[1];
|
47 |
|
|
}
|
48 |
|
|
|
49 |
3903add3
|
Phil Davis
|
/* 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 |
5262b29a
|
jim-p
|
}
|
55 |
|
|
|
56 |
|
|
/* If the filename is pkg_edit.php or wizard.php, reparse looking
|
57 |
a9c0ebfe
|
jim-p
|
for the .xml filename */
|
58 |
b873ded5
|
jim-p
|
if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "wizard.php")) {
|
59 |
5262b29a
|
jim-p
|
$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 |
3903add3
|
Phil Davis
|
if (strlen($pagename) > 0) {
|
71 |
0f2df9bb
|
jim-p
|
/* Clean up the page a little before attempting to use it in a redirect */
|
72 |
|
|
$pagename = urlencode(str_replace(array('%', ':', '..'), '', $pagename));
|
73 |
3903add3
|
Phil Davis
|
|
74 |
|
|
/* Redirect to help page. */
|
75 |
0f2df9bb
|
jim-p
|
header("Location: {$redirect_base}/{$pagename}");
|
76 |
5262b29a
|
jim-p
|
}
|
77 |
|
|
|
78 |
3903add3
|
Phil Davis
|
// No page name was determined, so show a message.
|
79 |
|
|
$pgtitle = array(gettext("Help"), gettext("About this Page"));
|
80 |
|
|
require_once("head.inc");
|
81 |
5262b29a
|
jim-p
|
|
82 |
3903add3
|
Phil Davis
|
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 |
5262b29a
|
jim-p
|
}
|
91 |
|
|
|
92 |
3903add3
|
Phil Davis
|
include("foot.inc");
|
93 |
5262b29a
|
jim-p
|
?>
|