-
-
Notifications
You must be signed in to change notification settings - Fork 389
/
global_session.php
151 lines (137 loc) · 6.18 KB
/
global_session.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2023 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/ |
+-------------------------------------------------------------------------+
*/
global $config, $refresh, $messages;
if (isset($_SESSION['automation_message']) && $_SESSION['automation_message'] != '') {
$messages['automation_message'] = array(
'message' => $_SESSION['automation_message'],
'type' => 'info'
);
kill_session_var('automation_message');
}
if (isset($_SESSION[CLOG_MESSAGE]) && $_SESSION[CLOG_MESSAGE] != '') {
$messages[CLOG_MESSAGE] = array(
'message' => $_SESSION[CLOG_MESSAGE],
'type' => 'info'
);
kill_session_var(CLOG_MESSAGE);
}
if (isset($_SESSION[CLOG_ERROR]) && $_SESSION[CLOG_ERROR] != '') {
$messages[CLOG_ERROR] = array(
'message' => $_SESSION[CLOG_ERROR],
'type' => 'error'
);
kill_session_var(CLOG_ERROR);
}
$script = basename($_SERVER['SCRIPT_NAME']);
if ($script == 'graph_view.php' || $script == 'graph.php') {
if (isset($_SESSION['custom']) && $_SESSION['custom'] == true) {
$refreshIsLogout = 'true';
} elseif (isset_request_var('action') && get_nfilter_request_var('action') == 'zoom') {
$refreshIsLogout = 'true';
} else {
$refresh = api_plugin_hook_function('top_graph_refresh', read_user_setting('page_refresh'));
$refreshIsLogout = 'false';
}
} elseif (strstr($_SERVER['SCRIPT_NAME'], 'plugins')) {
$refresh = api_plugin_hook_function('top_graph_refresh', $refresh);
if (empty($refresh)) {
$refreshIsLogout = 'true';
} else {
$refreshIsLogout = 'false';
}
}
if (isset($_SESSION['refresh'])) {
if (isset($_SESSION['refresh']['seconds'])) {
$myrefresh['seconds'] = $_SESSION['refresh']['seconds'];
} else {
$myrefresh['seconds'] = ini_get('session.gc_maxlifetime');
}
if (isset($_SESSION['refresh']['logout'])) {
$refreshIsLogout = $_SESSION['refresh']['logout'];
} else {
$refreshIsLogout = 'false';
}
if (isset($_SESSION['refresh']['page'])) {
$myrefresh['page'] = sanitize_uri($_SESSION['refresh']['page']);
} else {
$myrefresh['page'] = CACTI_PATH_URL . 'logout.php?action=timeout';
$refreshIsLogout = 'true';
}
unset($_SESSION['refresh']);
} elseif (isset($refresh) && is_array($refresh)) {
$myrefresh['seconds'] = $refresh['seconds'];
$myrefresh['page'] = sanitize_uri($refresh['page']);
$refreshIsLogout = 'false';
} elseif (isset($refresh)) {
$myrefresh['seconds'] = $refresh;
$myrefresh['page'] = sanitize_uri($_SERVER['REQUEST_URI']);
$refreshIsLogout = 'false';
} elseif (read_config_option('auth_cache_enabled') == 'on' && isset($_SESSION['cacti_remembers']) && $_SESSION['cacti_remembers'] == true) {
$myrefresh['seconds'] = 99999999;
$myrefresh['page'] = sanitize_uri($_SERVER['REQUEST_URI']);
$refreshIsLogout = 'false';
} elseif (read_user_setting('user_auto_logout_time') > 0 && is_realm_allowed(8)) {
$myrefresh['seconds'] = read_user_setting('user_auto_logout_time');
$myrefresh['page'] = CACTI_PATH_URL . 'logout.php?action=timeout';
$refreshIsLogout = 'true';
} elseif (read_config_option('auth_method') == AUTH_METHOD_BASIC) {
$myrefresh['seconds'] = 99999999;
$myrefresh['page'] = 'index.php';
$refreshIsLogout = 'false';
} elseif (!isset($_SESSION[SESS_USER_ID]) && isset($_SERVER['REQUEST_URL']) && strpos($_SERVER['REQUEST_URI'], 'index.php') !== false) {
$myrefresh['seconds'] = 99999999;
$myrefresh['page'] = sanitize_uri($_SERVER['REQUEST_URI']);
$refreshIsLogout = 'false';
} else {
$myrefresh['seconds'] = ini_get('session.gc_maxlifetime');
$myrefresh['page'] = CACTI_PATH_URL . 'logout.php?action=timeout';
$refreshIsLogout = 'true';
}
/* guest account does not auto log off */
if (isset($_SESSION[SESS_USER_ID]) && $_SESSION[SESS_USER_ID] == read_config_option('guest_user')) {
$myrefresh['seconds'] = 99999999;
$myrefresh['page'] = sanitize_uri($_SERVER['REQUEST_URI']);
$refreshIsLogout = 'false';
}
/* basic auth times out when the auth provider times out */
if (read_config_option('auth_method') == 2) {
$myrefresh['seconds'] = 99999999;
$myrefresh['page'] = sanitize_uri($_SERVER['REQUEST_URI']);
$refreshIsLogout = 'false';
}
?>
<script type='text/javascript'>
var cactiVersion='<?php print $config['cacti_version'];?>';
var cactiServerOS='<?php print $config['cacti_server_os'];?>';
var cactiAction='<?php print get_filter_request_var('action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([-a-zA-Z0-9_\s]+)$/')));?>';
var theme='<?php print get_selected_theme();?>';
var refreshIsLogout=<?php print $refreshIsLogout;?>;
var refreshPage='<?php print $myrefresh['page'];?>';
var refreshMSeconds=<?php print $myrefresh['seconds'] * 1000;?>;
var urlPath='<?php print CACTI_PATH_URL;?>';
var previousPage='';
var sessionNotices=<?php print display_output_messages();?>;
var sessionMessage={};
var csrfMagicToken='<?php print csrf_get_tokens();?>';
</script>