-
-
Notifications
You must be signed in to change notification settings - Fork 406
/
help.php
106 lines (95 loc) · 4.23 KB
/
help.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2024 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
$guest_account = true;
include('./include/auth.php');
if (isset_request_var('error')) {
$page = basename(get_nfilter_request_var('page'));
$error = get_filter_request_var('error');
if (isset($_SESSION['sess_user_id'])) {
$username = get_username($_SESSION['sess_user_id']);
} else {
$username = 'unknown';
}
$message = sprintf('WARNING: Cacti Page:%s for User:%s Generated a Fatal Error:%d', $page, $username, $error);
cacti_log($message, false);
if (debounce_run_notification('page_error_' . $page)) {
admin_email(__('Cacti System Warning'), __('WARNING: Cacti Page:%s for User:%s Generated a Fatal Error %d!', $page, $username, $error));
}
} elseif (isset_request_var('page')) {
get_filter_request_var('page', FILTER_CALLBACK, array('options' => 'sanitize_search_string'));
$page = str_replace('.html', '.md', get_request_var('page'));
$fgc_contextoption = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
'timeout' => 2,
'ignore_errors' => true
)
);
if (read_config_option('local_documentation') != 'on') {
$fgc_context = stream_context_create($fgc_contextoption);
$contents = @file_get_contents('https://docs.cacti.net/' . $page, false, $fgc_context);
$response_code = http_response_code();
} else {
$contents = '';
$response_code = 200;
}
if ($response_code != 200) {
print json_encode(
array(
'status' => 'Not Reachable',
'message' => __('The Document page \'%s\' count not be reached. The Cacti Documentation site is not reachable. The http error was \'%s\'. Consider downloading an official release to obtain the latest documentation and hosting the documentation locally.', $page, $response_code)
)
);
} elseif ($contents != '' && !preg_match('/does not appear to exist/i', $contents)) {
print json_encode(
array(
'status' => 'Success',
'location' => 'https://docs.cacti.net/' . $page
)
);
} elseif ($contents != '' && preg_match('/does not appear to exist/i', $contents)) {
print json_encode(
array(
'status' => 'Not Found',
'location' => __esc('The Help File %s was not located on the Cacti Documentation Website.', $page) . '<br><br>' . __esc('Open a ticket at ') . '<a target="_blank" href="https://github.com/cacti/cacti/issues">' . __esc('Cacti GitHub Site') . '</a>.'
)
);
} elseif (file_exists(CACTI_PATH_DOCS . '/' . $page)) {
print json_encode(
array(
'status' => 'Success',
'location' => CACTI_PATH_URL . 'docs/' . $page
)
);
} else {
print json_encode(
array(
'status' => 'Not Reachable',
'message' => __('The Document page \'%s\' count not be reached locally.', $page, $response_code)
)
);
}
}