]> git.pld-linux.org Git - packages/cacti.git/blame - cacti-PA.patch
- updated PA patch to 2.8; rel 1
[packages/cacti.git] / cacti-PA.patch
CommitLineData
1c1c23da
SP
1diff -Naur cacti-0.8.7g-old/auth_changepassword.php cacti-0.8.7g/auth_changepassword.php
2--- cacti-0.8.7g-old/auth_changepassword.php 2010-07-09 18:33:46.000000000 -0400
3+++ cacti-0.8.7g/auth_changepassword.php 2010-07-09 18:34:11.000000000 -0400
c9a520e2
ER
4@@ -59,6 +59,8 @@
5 header("Location: index.php"); break;
6 case '3': /* default graph page */
7 header("Location: graph_view.php"); break;
8+ default:
9+ api_plugin_hook_function('login_options_navigate', $user['login_opts']);
10 }
11 }else{
12 header("Location: graph_view.php");
1c1c23da
SP
13diff -Naur cacti-0.8.7g-old/auth_login.php cacti-0.8.7g/auth_login.php
14--- cacti-0.8.7g-old/auth_login.php 2010-07-09 18:33:46.000000000 -0400
15+++ cacti-0.8.7g/auth_login.php 2010-07-09 18:34:11.000000000 -0400
16@@ -124,10 +124,12 @@
ac01d3f9
AZ
17 }
18
19 default:
20- /* Builtin Auth */
21- if ((!$user_auth) && (!$ldap_error)) {
22- /* if auth has not occured process for builtin - AKA Ldap fall through */
23- $user = db_fetch_row("SELECT * FROM user_auth WHERE username = '" . $username . "' AND password = '" . md5(get_request_var_post("login_password")) . "' AND realm = 0");
24+ if (!api_plugin_hook_function('login_process', false)) {
25+ /* Builtin Auth */
26+ if ((!$user_auth) && (!$ldap_error)) {
27+ /* if auth has not occured process for builtin - AKA Ldap fall through */
28+ $user = db_fetch_row("SELECT * FROM user_auth WHERE username = '" . $username . "' AND password = '" . md5(get_request_var_post("login_password")) . "' AND realm = 0");
29+ }
30 }
31 }
32 /* end of switch */
1c1c23da 33@@ -189,29 +191,42 @@
ac01d3f9
AZ
34 decide what to do next */
35 switch ($user["login_opts"]) {
36 case '1': /* referer */
37- if (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE realm_id = 8 AND user_id = " . $_SESSION["sess_user_id"])) == 0) {
38- header("Location: graph_view.php");
39- }else{
40- if (isset($_SERVER["HTTP_REFERER"])) {
41- $referer = $_SERVER["HTTP_REFERER"];
42- if (basename($referer) == "logout.php") {
43- $referer = "index.php";
44- }
45- } else if (isset($_SERVER["REQUEST_URI"])) {
46- $referer = $_SERVER["REQUEST_URI"];
47- if (basename($referer) == "logout.php") {
48- $referer = "index.php";
49- }
50- } else {
51- $referer = "index.php";
52+ /* because we use plugins, we can't redirect back to graph_view.php if they don't
53+ * have console access
54+ */
55+ if (isset($_SERVER["HTTP_REFERER"])) {
56+ $referer = $_SERVER["HTTP_REFERER"];
57+ if (basename($referer) == "logout.php") {
58+ $referer = $config['url_path'] . "index.php";
1c1c23da 59+ }
ac01d3f9
AZ
60+ } else if (isset($_SERVER["REQUEST_URI"])) {
61+ $referer = $_SERVER["REQUEST_URI"];
62+ if (basename($referer) == "logout.php") {
63+ $referer = $config['url_path'] . "index.php";
1c1c23da 64 }
ac01d3f9
AZ
65+ } else {
66+ $referer = $config['url_path'] . "index.php";
1c1c23da
SP
67+ }
68+
69+ if (substr_count($referer, "plugins")) {
70 header("Location: " . $referer);
71+ } elseif (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE realm_id = 8 AND user_id = " . $_SESSION["sess_user_id"])) == 0) {
72+ header("Location: graph_view.php");
73+ } else {
74+ header("Location: $referer");
ac01d3f9 75 }
ac01d3f9
AZ
76+
77 break;
78 case '2': /* default console page */
79- header("Location: index.php"); break;
80+ header("Location: " . $config['url_path'] . "index.php");
81+
82+ break;
c9a520e2 83 case '3': /* default graph page */
ac01d3f9
AZ
84- header("Location: graph_view.php"); break;
85+ header("Location: " . $config['url_path'] . "graph_view.php");
86+
87+ break;
c9a520e2
ER
88+ default:
89+ api_plugin_hook_function('login_options_navigate', $user['login_opts']);
90 }
91 exit;
ac01d3f9 92 }else{
1c1c23da 93@@ -264,9 +279,17 @@
c9a520e2
ER
94 <body bgcolor="#FFFFFF" onload="document.login.login_username.focus()">
95 <form name="login" method="post" action="<?php print basename($_SERVER["PHP_SELF"]);?>">
96 <input type="hidden" name="action" value="login">
97+<?php
98+
99+api_plugin_hook("login_before");
100+
101+$cacti_logo = $config['url_path'] . 'images/auth_login.gif';
102+$cacti_logo = api_plugin_hook_function('cacti_image', $cacti_logo);
103+
104+?>
105 <table align="center">
106 <tr>
107- <td colspan="2"><img src="images/auth_login.gif" border="0" alt=""></td>
ac01d3f9 108+ <td colspan="2"><center><?php if ($cacti_logo != '') { ?><img src="<?php echo $cacti_logo; ?>" border="0" alt=""><?php } ?></center></td>
c9a520e2
ER
109 </tr>
110 <?php
111
1c1c23da 112@@ -303,22 +326,29 @@
ac01d3f9
AZ
113 <td><input type="password" name="login_password" size="40" style="width: 295px;"></td>
114 </tr>
115 <?php
116- if (read_config_option("auth_method") == "3") {?>
117+ if (read_config_option("auth_method") == "3" || api_plugin_hook_function('login_realms_exist')) {
118+ $realms = api_plugin_hook_function('login_realms', array("local" => array("name" => "Local", "selected" => false), "ldap" => array("name" => "LDAP", "selected" => true)));
119+ ?>
120 <tr>
121 <td>Realm:</td>
122 <td>
123- <select name="realm" style="width: 295px;">
124- <option value="local">Local</option>
125- <option value="ldap" selected>LDAP</option>
126+ <select name="realm" style="width: 295px;"><?php
127+ if (sizeof($realms)) {
128+ foreach($realms as $name => $realm) {
1c1c23da 129+ print "\t\t\t\t\t<option value='" . $name . "'" . ($realm["selected"] ? " selected":"") . ">" . htmlspecialchars($realm["name"]) . "</option>\n";
ac01d3f9
AZ
130+ }
131+ }
132+ ?>
133 </select>
134 </td>
135- </tr>
136+ </tr>
137 <?php }?>
138 <tr style="height:10px;"><td></td></tr>
139 <tr>
c9a520e2
ER
140 <td><input type="submit" value="Login"></td>
141 </tr>
142 </table>
143+<?php api_plugin_hook('login_after'); ?>
144 </form>
145 </body>
146 </html>
1c1c23da
SP
147diff -Naur cacti-0.8.7g-old/data_sources.php cacti-0.8.7g/data_sources.php
148--- cacti-0.8.7g-old/data_sources.php 2010-07-09 18:33:46.000000000 -0400
149+++ cacti-0.8.7g/data_sources.php 2010-07-09 18:34:11.000000000 -0400
c9a520e2
ER
150@@ -44,6 +44,8 @@
151 7 => "Disable"
152 );
153
154+$ds_actions = api_plugin_hook_function('data_source_action_array', $ds_actions);
155+
156 /* set default action */
157 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
158
ac01d3f9 159@@ -402,6 +404,8 @@
c9a520e2
ER
160 api_reapply_suggested_data_source_title($selected_items[$i]);
161 update_data_source_title_cache($selected_items[$i]);
162 }
163+ } else {
164+ api_plugin_hook_function('data_source_action_execute', $_POST['drp_action']);
165 }
c9a520e2
ER
166 header("Location: data_sources.php");
167 exit;
ac01d3f9
AZ
168@@ -545,6 +549,12 @@
169 </tr>\n
170 ";
171 $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Reapply Suggested Naming to Data Source(s)'>";
172+ }else{
173+ $save['drp_action'] = $_POST['drp_action'];
174+ $save['ds_list'] = $ds_list;
175+ $save['ds_array'] = (isset($ds_array)? $ds_array : array());
176+ api_plugin_hook_function('data_source_action_prepare', $save);
177+ $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
178 }
179 }else{
180 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one data source.</span></td></tr>\n";
181@@ -683,6 +693,8 @@
182 input_validate_input_number(get_request_var("host_id"));
c9a520e2
ER
183 /* ==================================================== */
184
185+ api_plugin_hook('data_source_edit_top');
186+
187 $use_data_template = true;
188 $host_id = 0;
189
ac01d3f9 190@@ -975,8 +987,9 @@
c9a520e2
ER
191
192 form_save_button("data_sources.php");
193
194- include_once("./include/bottom_footer.php");
195+ api_plugin_hook('data_source_edit_bottom');
196
197+ include_once("./include/bottom_footer.php");
198 }
199
200 function get_poller_interval($seconds) {
ac01d3f9 201@@ -1310,6 +1323,7 @@
c9a520e2
ER
202 $i = 0;
203 if (sizeof($data_sources) > 0) {
204 foreach ($data_sources as $data_source) {
205+ $data_source = api_plugin_hook_function('data_sources_table', $data_source);
206 $data_template_name = ((empty($data_source["data_template_name"])) ? "<em>None</em>" : $data_source["data_template_name"]);
207 $data_input_name = ((empty($data_source["data_input_name"])) ? "<em>External</em>" : $data_source["data_input_name"]);
208 $poller_interval = ((isset($poller_intervals[$data_source["local_data_id"]])) ? $poller_intervals[$data_source["local_data_id"]] : 0);
1c1c23da
SP
209diff -Naur cacti-0.8.7g-old/graph_image.php cacti-0.8.7g/graph_image.php
210--- cacti-0.8.7g-old/graph_image.php 2010-07-09 18:33:46.000000000 -0400
211+++ cacti-0.8.7g/graph_image.php 2010-07-09 18:34:11.000000000 -0400
c9a520e2
ER
212@@ -44,6 +44,8 @@
213 /* flush the headers now */
214 ob_end_clean();
215
216+api_plugin_hook_function('graph_image');
217+
218 session_write_close();
219
220 $graph_data_array = array();
1c1c23da
SP
221diff -Naur cacti-0.8.7g-old/graph.php cacti-0.8.7g/graph.php
222--- cacti-0.8.7g-old/graph.php 2010-07-09 18:33:46.000000000 -0400
223+++ cacti-0.8.7g/graph.php 2010-07-09 18:34:11.000000000 -0400
224@@ -32,6 +32,8 @@
225 include_once("./lib/html_tree.php");
226 include_once("./include/top_graph_header.php");
227
228+api_plugin_hook_function('graph');
229+
230 /* ================= input validation ================= */
231 input_validate_input_regex(get_request_var("rra_id"), "^([0-9]+|all)$");
232 input_validate_input_number(get_request_var("local_graph_id"));
233@@ -94,17 +96,18 @@
234 <table width='1' cellpadding='0'>
235 <tr>
236 <td>
237- <img class='graphimage' id='graph_<?php print $_GET["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?action=view&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"]);?>' border='0' alt='<?php print htmlspecialchars($graph_title);?>'>
238+ <img class='graphimage' id='graph_<?php print $_GET["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?action=view&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"]);?>' border='0' alt='<?php print htmlspecialchars($graph_title);?>'>
239 </td>
240 <td valign='top' style='padding: 3px;' class='noprint'>
241 <a href='<?php print htmlspecialchars("graph.php?action=zoom&local_graph_id=" . $_GET["local_graph_id"]. "&rra_id=" . $rra["id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
242 <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
243 <a href='<?php print htmlspecialchars("graph.php?action=properties&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a>
244+ <?php api_plugin_hook('graph_buttons', array('hook' => 'view', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $rra['id'], 'view_type' => $_REQUEST['view_type'])); ?>
245 </td>
246 </tr>
247 <tr>
248 <td colspan='2' align='center'>
249- <strong><?php print htmlspecialchars($rra["name"]);?></strong>
250+ <strong><?php print htmlspecialchars($rra["name"]);?></strong>
251 </td>
252 </tr>
253 </table>
254@@ -215,6 +218,7 @@
c9a520e2 255 <td valign='top' style='padding: 3px;' class='noprint'>
ac01d3f9
AZ
256 <a href='<?php print htmlspecialchars("graph.php?action=properties&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_REQUEST["view_type"] . "&graph_start=" . $graph_start . "&graph_end=" . $graph_end);?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a>
257 <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_REQUEST["view_type"]);?>&graph_start=<?php print $graph_start;?>&graph_end=<?php print $graph_end;?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
c9a520e2
ER
258+ <?php api_plugin_hook('graph_buttons', array('hook' => 'zoom', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $_GET['rra_id'], 'view_type' => $_REQUEST['view_type'])); ?>
259 </td>
260 </tr>
261 <tr>
1c1c23da 262@@ -247,6 +251,7 @@
c9a520e2 263 <td valign='top' style='padding: 3px;'>
ac01d3f9
AZ
264 <a href='<?php print htmlspecialchars("graph.php?action=zoom&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
265 <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
c9a520e2
ER
266+ <?php api_plugin_hook('graph_buttons', array('hook' => 'properties', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $_GET['rra_id'], 'view_type' => $_REQUEST['view_type'])); ?>
267 </td>
268 </tr>
269 <tr>
1c1c23da
SP
270diff -Naur cacti-0.8.7g-old/graphs_new.php cacti-0.8.7g/graphs_new.php
271--- cacti-0.8.7g-old/graphs_new.php 2010-07-09 18:33:46.000000000 -0400
272+++ cacti-0.8.7g/graphs_new.php 2010-07-09 18:34:11.000000000 -0400
273@@ -511,7 +511,8 @@
c9a520e2
ER
274 </td>
275 <td nowrap style='white-space: nowrap;' class="textInfo" align="center" valign="top">
ac01d3f9
AZ
276 <span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit&id=" . $_REQUEST["host_id"]);?>">Edit this Host</a><br>
277- <span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit");?>">Create New Host</a>
278+ <span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit");?>">Create New Host</a><br>
c9a520e2
ER
279+ <?php api_plugin_hook('graphs_new_top_links'); ?>
280 </td>
281 </tr>
282 </table>
1c1c23da
SP
283diff -Naur cacti-0.8.7g-old/graphs.php cacti-0.8.7g/graphs.php
284--- cacti-0.8.7g-old/graphs.php 2010-07-09 18:33:46.000000000 -0400
285+++ cacti-0.8.7g/graphs.php 2010-07-09 18:34:11.000000000 -0400
c9a520e2
ER
286@@ -45,6 +45,8 @@
287 4 => "Convert to Graph Template"
288 );
289
290+$graph_actions = api_plugin_hook_function('graphs_action_array', $graph_actions);
291+
292 /* set default action */
293 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
294
ac01d3f9 295@@ -362,6 +364,8 @@
c9a520e2 296
ac01d3f9 297 api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
c9a520e2
ER
298 }
299+ } else {
ac01d3f9 300+ api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
c9a520e2
ER
301 }
302
303 header("Location: graphs.php");
ac01d3f9
AZ
304@@ -514,6 +518,12 @@
305 ";
c9a520e2 306
ac01d3f9
AZ
307 $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Resize Selected Graph(s)'>";
308+ } else {
309+ $save['drp_action'] = $_POST['drp_action'];
310+ $save['graph_list'] = $graph_list;
311+ $save['graph_array'] = (isset($graph_array) ? $graph_array : array());
312+ api_plugin_hook_function('graphs_action_prepare', $save);
313+ $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
314 }
315 }else{
316 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one graph.</span></td></tr>\n";
1c1c23da
SP
317diff -Naur cacti-0.8.7g-old/host.php cacti-0.8.7g/host.php
318--- cacti-0.8.7g-old/host.php 2010-07-09 18:33:46.000000000 -0400
319+++ cacti-0.8.7g/host.php 2010-07-09 18:34:11.000000000 -0400
c9a520e2
ER
320@@ -44,6 +44,8 @@
321 6 => "Change Availability Options"
322 );
323
324+$device_actions = api_plugin_hook_function('device_action_array', $device_actions);
325+
326 /* set default action */
327 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
328
ac01d3f9 329@@ -305,6 +307,8 @@
c9a520e2
ER
330
331 api_tree_item_save(0, $_POST["tree_id"], TREE_ITEM_TYPE_HOST, $_POST["tree_item_id"], "", 0, read_graph_config_option("default_rra_id"), $selected_items[$i], 1, 1, false);
332 }
333+ } else {
334+ api_plugin_hook_function('device_action_execute', $_POST['drp_action']);
335 }
336
337 header("Location: host.php");
ac01d3f9
AZ
338@@ -450,6 +454,12 @@
339 <input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
340 ";
341 $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Place Device(s) on Tree'>";
342+ } else {
343+ $save['drp_action'] = $_POST['drp_action'];
344+ $save['host_list'] = $host_list;
345+ $save['host_array'] = (isset($host_array)? $host_array : array());
346+ api_plugin_hook_function('device_action_prepare', $save);
1c1c23da 347+ $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
ac01d3f9
AZ
348 }
349 }else{
350 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one device.</span></td></tr>\n";
351@@ -532,6 +542,8 @@
352 input_validate_input_number(get_request_var("id"));
353 /* ==================================================== */
c9a520e2
ER
354
355+ api_plugin_hook('host_edit_top');
356+
357 if (!empty($_GET["id"])) {
358 $host = db_fetch_row("select * from host where id=" . $_GET["id"]);
1c1c23da 359 $header_label = "[edit: " . htmlspecialchars($host["description"]) . "]";
ac01d3f9
AZ
360@@ -643,6 +655,7 @@
361 <span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs_new.php?host_id=" . $host["id"]);?>">Create Graphs for this Host</a><br>
362 <span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("data_sources.php?host_id=" . $host["id"] . "&ds_rows=30&filter=&template_id=-1&method_id=-1&page=1");?>">Data Source List</a><br>
363 <span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs.php?host_id=" . $host["id"] . "&graph_rows=30&filter=&template_id=-1&page=1");?>">Graph List</a>
c9a520e2
ER
364+ <?php api_plugin_hook('device_edit_top_links'); ?>
365 </td>
366 </tr>
367 </table>
ac01d3f9 368@@ -1107,6 +1120,8 @@
c9a520e2
ER
369 }
370
ac01d3f9 371 form_save_button("host.php", "return");
c9a520e2
ER
372+
373+ api_plugin_hook('host_edit_bottom');
374 }
375
376 function host() {
1c1c23da
SP
377diff -Naur cacti-0.8.7g-old/images/disable_icon.png cacti-0.8.7g/images/disable_icon.png
378--- cacti-0.8.7g-old/images/disable_icon.png 1969-12-31 19:00:00.000000000 -0500
379+++ cacti-0.8.7g/images/disable_icon.png 2010-07-09 18:34:11.000000000 -0400
380@@ -0,0 +1,4 @@
381