]>
Commit | Line | Data |
---|---|---|
1c1c23da SP |
1 | diff -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 |
13 | diff -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 |
147 | diff -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()'> <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()'> <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 |
209 | diff -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 |
221 | diff -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 |
270 | diff -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 |
283 | diff -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()'> <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()'> <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 |
317 | diff -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()'> <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()'> <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 |
377 | \ No newline at end of file |
378 | diff -Naur cacti-0.8.7g-old/include/auth.php cacti-0.8.7g/include/auth.php | |
379 | --- cacti-0.8.7g-old/include/auth.php 2010-07-09 18:33:46.000000000 -0400 | |
380 | +++ cacti-0.8.7g/include/auth.php 2010-07-09 18:34:11.000000000 -0400 | |
c9a520e2 ER |
381 | @@ -31,6 +31,9 @@ |
382 | } | |
383 | ||
384 | if (read_config_option("auth_method") != 0) { | |
ac01d3f9 | 385 | + /* handle alternate authentication realms */ |
c9a520e2 ER |
386 | + api_plugin_hook_function('auth_alternate_realms'); |
387 | + | |
388 | /* handle change password dialog */ | |
389 | if ((isset($_SESSION['sess_change_password'])) && (read_config_option("webbasic_enabled") != "on")) { | |
390 | header ("Location: auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php")); | |
ac01d3f9 AZ |
391 | @@ -72,9 +75,9 @@ |
392 | and user_auth_realm.realm_id='$realm_id'")) || (empty($realm_id)))) { | |
393 | ||
394 | if (isset($_SERVER["HTTP_REFERER"])) { | |
395 | - $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . htmlspecialchars($_SERVER["HTTP_REFERER"]) . "'>Return</a> | <a href='logout.php'>Login Again</a> )</td>"; | |
396 | + $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . htmlspecialchars($_SERVER["HTTP_REFERER"]) . "'>Return</a> | <a href='" . $config['url_path'] . "logout.php'>Login Again</a> )</td>"; | |
397 | }else{ | |
398 | - $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='logout.php'>Login Again</a> )</td>"; | |
399 | + $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . $config['url_path'] . "logout.php'>Login Again</a> )</td>"; | |
400 | } | |
401 | ||
402 | ?> | |
1c1c23da | 403 | @@ -83,14 +86,14 @@ |
c9a520e2 ER |
404 | <head> |
405 | <title>Cacti</title> | |
1c1c23da | 406 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> |
ac01d3f9 AZ |
407 | - <link href="include/main.css" type="text/css" rel="stylesheet"> |
408 | + <link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet"> | |
c9a520e2 | 409 | </head> |
ac01d3f9 AZ |
410 | <body> |
411 | <br><br> | |
c9a520e2 ER |
412 | |
413 | <table width="450" align='center'> | |
414 | <tr> | |
415 | - <td colspan='2'><img src='images/auth_deny.gif' border='0' alt='Access Denied'></td> | |
416 | + <td colspan='2'><img src='<?php echo $config['url_path']; ?>images/auth_deny.gif' border='0' alt='Access Denied'></td> | |
417 | </tr> | |
ac01d3f9 | 418 | <tr style='height:10px;'><td></td></tr> |
c9a520e2 | 419 | <tr> |
1c1c23da SP |
420 | diff -Naur cacti-0.8.7g-old/include/bottom_footer.php cacti-0.8.7g/include/bottom_footer.php |
421 | --- cacti-0.8.7g-old/include/bottom_footer.php 2010-07-09 18:33:46.000000000 -0400 | |
422 | +++ cacti-0.8.7g/include/bottom_footer.php 2010-07-09 18:34:11.000000000 -0400 | |
c9a520e2 ER |
423 | @@ -21,6 +21,10 @@ |
424 | | http://www.cacti.net/ | | |
425 | +-------------------------------------------------------------------------+ | |
426 | */ | |
427 | + | |
428 | +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE); | |
429 | +if (($oper_mode == OPER_MODE_NATIVE) || ($oper_mode == OPER_MODE_IFRAME_NONAV)) { | |
430 | + | |
431 | ?> | |
ac01d3f9 | 432 | </div> |
c9a520e2 | 433 | <br> |
ac01d3f9 | 434 | @@ -32,6 +36,9 @@ |
c9a520e2 ER |
435 | </html> |
436 | ||
437 | <?php | |
438 | + | |
439 | +} | |
440 | + | |
441 | /* we use this session var to store field values for when a save fails, | |
442 | this way we can restore the field's previous values. we reset it here, because | |
443 | they only need to be stored for a single page */ | |
1c1c23da SP |
444 | diff -Naur cacti-0.8.7g-old/include/config.php cacti-0.8.7g/include/config.php |
445 | --- cacti-0.8.7g-old/include/config.php 2010-07-09 18:33:46.000000000 -0400 | |
446 | +++ cacti-0.8.7g/include/config.php 2010-07-09 18:34:11.000000000 -0400 | |
447 | @@ -30,6 +30,17 @@ | |
448 | $database_password = "cactiuser"; | |
449 | $database_port = "3306"; | |
450 | ||
451 | +/* load up old style plugins here */ | |
452 | +$plugins = array(); | |
453 | +//$plugins[] = 'thold'; | |
454 | + | |
455 | +/* | |
456 | + Edit this to point to the default URL of your Cacti install | |
457 | + ex: if your cacti install as at http://serverip/cacti/ this | |
458 | + would be set to /cacti/ | |
459 | +*/ | |
460 | +$url_path = "/"; | |
461 | + | |
462 | /* Default session name - Session name must contain alpha characters */ | |
463 | #$cacti_session_name = "Cacti"; | |
464 | ||
465 | diff -Naur cacti-0.8.7g-old/include/global_arrays.php cacti-0.8.7g/include/global_arrays.php | |
466 | --- cacti-0.8.7g-old/include/global_arrays.php 2010-07-09 18:33:46.000000000 -0400 | |
467 | +++ cacti-0.8.7g/include/global_arrays.php 2010-07-09 18:34:11.000000000 -0400 | |
c9a520e2 ER |
468 | @@ -22,6 +22,8 @@ |
469 | +-------------------------------------------------------------------------+ | |
470 | */ | |
471 | ||
472 | +global $menu; | |
473 | + | |
474 | $messages = array( | |
475 | 1 => array( | |
476 | "message" => 'Save Successful.', | |
1c1c23da | 477 | @@ -654,4 +656,10 @@ |
c9a520e2 ER |
478 | GDC_SLASH => "/" |
479 | ); | |
480 | ||
481 | +$plugin_architecture = array( | |
1c1c23da | 482 | + 'version' => '2.8' |
c9a520e2 ER |
483 | + ); |
484 | + | |
485 | +api_plugin_hook('config_arrays'); | |
486 | + | |
487 | ?> | |
1c1c23da SP |
488 | diff -Naur cacti-0.8.7g-old/include/global_constants.php cacti-0.8.7g/include/global_constants.php |
489 | --- cacti-0.8.7g-old/include/global_constants.php 2010-07-09 18:33:46.000000000 -0400 | |
490 | +++ cacti-0.8.7g/include/global_constants.php 2010-07-09 18:34:11.000000000 -0400 | |
491 | @@ -173,4 +173,8 @@ | |
c9a520e2 ER |
492 | define("SNMP_CMDPHP", 1); |
493 | define("SNMP_WEBUI", 2); | |
494 | ||
ac01d3f9 | 495 | -?> |
c9a520e2 ER |
496 | +define('OPER_MODE_NATIVE', 0); |
497 | +define('OPER_MODE_RESKIN', 1); | |
498 | +define('OPER_MODE_IFRAME_NONAV', 2); | |
499 | + | |
ac01d3f9 AZ |
500 | +?> |
501 | \ No newline at end of file | |
1c1c23da SP |
502 | diff -Naur cacti-0.8.7g-old/include/global_form.php cacti-0.8.7g/include/global_form.php |
503 | --- cacti-0.8.7g-old/include/global_form.php 2010-07-09 18:33:46.000000000 -0400 | |
504 | +++ cacti-0.8.7g/include/global_form.php 2010-07-09 18:34:11.000000000 -0400 | |
c9a520e2 ER |
505 | @@ -22,8 +22,9 @@ |
506 | +-------------------------------------------------------------------------+ | |
507 | */ | |
508 | ||
509 | -if (!defined("VALID_HOST_FIELDS")) { | |
510 | - define("VALID_HOST_FIELDS", "(hostname|snmp_community|snmp_username|snmp_password|snmp_auth_protocol|snmp_priv_passphrase|snmp_priv_protocol|snmp_context|snmp_version|snmp_port|snmp_timeout)"); | |
511 | +if (!defined('VALID_HOST_FIELDS')) { | |
512 | + $string = api_plugin_hook_function('valid_host_fields', '(hostname|snmp_community|snmp_username|snmp_password|snmp_auth_protocol|snmp_priv_passphrase|snmp_priv_protocol|snmp_context|snmp_version|snmp_port|snmp_timeout)'); | |
513 | + define('VALID_HOST_FIELDS', $string); | |
514 | } | |
515 | ||
516 | /* file: cdef.php, action: edit */ | |
ac01d3f9 | 517 | @@ -1190,4 +1191,7 @@ |
c9a520e2 ER |
518 | "dropdown_sql" => "select id,name from snmp_query order by name" |
519 | ) | |
520 | ); | |
521 | -?> | |
522 | + | |
523 | + | |
524 | +api_plugin_hook('config_form'); | |
525 | + | |
1c1c23da SP |
526 | diff -Naur cacti-0.8.7g-old/include/global.php cacti-0.8.7g/include/global.php |
527 | --- cacti-0.8.7g-old/include/global.php 2010-07-09 18:33:46.000000000 -0400 | |
528 | +++ cacti-0.8.7g/include/global.php 2010-07-09 18:34:11.000000000 -0400 | |
529 | @@ -93,6 +93,13 @@ | |
530 | /* built-in snmp support */ | |
531 | $config["php_snmp_support"] = function_exists("snmpget"); | |
c9a520e2 | 532 | |
1c1c23da SP |
533 | +/* set URL path */ |
534 | +if (! isset($url_path)) { | |
535 | + $url_path = ""; | |
536 | +} | |
537 | +$config['url_path'] = $url_path; | |
538 | +define('URL_PATH', $url_path); | |
c9a520e2 | 539 | + |
1c1c23da SP |
540 | /* used for includes */ |
541 | $config["base_path"] = strtr(ereg_replace("(.*)[\\\/]include", "\\1", dirname(__FILE__)), "\\", "/"); | |
542 | $config["library_path"] = ereg_replace("(.*[\\\/])include", "\\1lib", dirname(__FILE__)); | |
543 | @@ -188,15 +195,17 @@ | |
c9a520e2 ER |
544 | /* include base modules */ |
545 | include($config["library_path"] . "/adodb/adodb.inc.php"); | |
546 | include($config["library_path"] . "/database.php"); | |
547 | -include_once($config["library_path"] . "/functions.php"); | |
548 | -include_once($config["include_path"] . "/global_constants.php"); | |
549 | -include_once($config["include_path"] . "/global_arrays.php"); | |
550 | -include_once($config["include_path"] . "/global_settings.php"); | |
551 | ||
552 | /* connect to the database server */ | |
553 | db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port); | |
554 | ||
555 | /* include additional modules */ | |
556 | +include_once($config["library_path"] . "/functions.php"); | |
557 | +include_once($config["include_path"] . "/global_constants.php"); | |
558 | +include_once($config["library_path"] . "/plugins.php"); | |
559 | +include_once($config["include_path"] . "/plugins.php"); | |
560 | +include_once($config["include_path"] . "/global_arrays.php"); | |
561 | +include_once($config["include_path"] . "/global_settings.php"); | |
562 | include_once($config["include_path"] . "/global_form.php"); | |
563 | include_once($config["library_path"] . "/html.php"); | |
564 | include_once($config["library_path"] . "/html_form.php"); | |
1c1c23da | 565 | @@ -205,6 +214,8 @@ |
c9a520e2 ER |
566 | include_once($config["library_path"] . "/variables.php"); |
567 | include_once($config["library_path"] . "/auth.php"); | |
568 | ||
569 | +api_plugin_hook("config_insert"); | |
570 | + | |
571 | /* current cacti version */ | |
1c1c23da | 572 | $config["cacti_version"] = "0.8.7g"; |
c9a520e2 | 573 | |
1c1c23da SP |
574 | diff -Naur cacti-0.8.7g-old/include/global_settings.php cacti-0.8.7g/include/global_settings.php |
575 | --- cacti-0.8.7g-old/include/global_settings.php 2010-07-09 18:33:46.000000000 -0400 | |
576 | +++ cacti-0.8.7g/include/global_settings.php 2010-07-09 18:34:11.000000000 -0400 | |
577 | @@ -1190,4 +1190,6 @@ | |
c9a520e2 ER |
578 | ) |
579 | ); | |
580 | ||
581 | +api_plugin_hook('config_settings'); | |
582 | + | |
583 | ?> | |
1c1c23da SP |
584 | diff -Naur cacti-0.8.7g-old/include/plugins.php cacti-0.8.7g/include/plugins.php |
585 | --- cacti-0.8.7g-old/include/plugins.php 1969-12-31 19:00:00.000000000 -0500 | |
586 | +++ cacti-0.8.7g/include/plugins.php 2010-07-09 18:34:11.000000000 -0400 | |
587 | @@ -0,0 +1,38 @@ | |
c9a520e2 ER |
588 | +<?php |
589 | + | |
590 | +/* | |
591 | + * Copyright (c) 1999-2005 The SquirrelMail Project Team (http://squirrelmail.org) | |
592 | + * Licensed under the GNU GPL. For full terms see the file COPYING. | |
593 | + */ | |
594 | + | |
1c1c23da | 595 | +global $plugin_hooks, $plugins_system; |
c9a520e2 | 596 | +$plugin_hooks = array(); |
1c1c23da | 597 | +$plugins_system = array('settings', 'boost', 'dsstats'); |
c9a520e2 ER |
598 | + |
599 | +function use_plugin ($name) { | |
1c1c23da SP |
600 | + global $config; |
601 | + if (file_exists($config['base_path'] . "/plugins/$name/setup.php")) { | |
602 | + include_once($config['base_path'] . "/plugins/$name/setup.php"); | |
603 | + $function = "plugin_init_$name"; | |
604 | + if (function_exists($function)) { | |
605 | + $function(); | |
606 | + } | |
607 | + } | |
c9a520e2 ER |
608 | +} |
609 | + | |
610 | +/** | |
611 | + * This function executes a hook. | |
612 | + * @param string $name Name of hook to fire | |
613 | + * @return mixed $data | |
614 | + */ | |
615 | + | |
1c1c23da SP |
616 | +$oldplugins = read_config_option('oldplugins'); |
617 | +$oldplugins = explode(',', $oldplugins); | |
618 | +$plugins = array_merge($plugins, $oldplugins); | |
619 | + | |
c9a520e2 ER |
620 | +/* On startup, register all plugins configured for use. */ |
621 | +if (isset($plugins) && is_array($plugins)) { | |
1c1c23da SP |
622 | + foreach ($plugins as $name) { |
623 | + use_plugin($name); | |
624 | + } | |
c9a520e2 | 625 | +} |
1c1c23da SP |
626 | diff -Naur cacti-0.8.7g-old/include/top_graph_header.php cacti-0.8.7g/include/top_graph_header.php |
627 | --- cacti-0.8.7g-old/include/top_graph_header.php 2010-07-09 18:33:46.000000000 -0400 | |
628 | +++ cacti-0.8.7g/include/top_graph_header.php 2010-07-09 18:34:11.000000000 -0400 | |
c9a520e2 ER |
629 | @@ -25,6 +25,11 @@ |
630 | $using_guest_account = false; | |
631 | $show_console_tab = true; | |
632 | ||
633 | +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE); | |
634 | +if ($oper_mode == OPER_MODE_RESKIN) { | |
635 | + return; | |
636 | +} | |
637 | + | |
638 | /* ================= input validation ================= */ | |
639 | input_validate_input_number(get_request_var_request("local_graph_id")); | |
1c1c23da SP |
640 | input_validate_input_number(get_request_var_request("graph_start")); |
641 | @@ -52,41 +57,53 @@ | |
c9a520e2 ER |
642 | $_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all"; |
643 | } | |
644 | ||
ac01d3f9 | 645 | +$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title")); |
c9a520e2 ER |
646 | + |
647 | ?> | |
ac01d3f9 | 648 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
c9a520e2 ER |
649 | <html> |
650 | <head> | |
ac01d3f9 | 651 | - <title><?php echo draw_navigation_text("title");?></title> |
c9a520e2 | 652 | + <title><?php echo $page_title; ?></title> |
ac01d3f9 | 653 | <?php |
1c1c23da | 654 | if (isset($_SESSION["custom"]) && $_SESSION["custom"] == true) { |
ac01d3f9 AZ |
655 | print "<meta http-equiv=refresh content='99999'>\r\n"; |
656 | }else{ | |
657 | - print "<meta http-equiv=refresh content='" . htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES) . "'>\r\n"; | |
1c1c23da | 658 | + $refresh = api_plugin_hook_function('top_graph_refresh', htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES)); |
ac01d3f9 | 659 | + print "<meta http-equiv=refresh content='" . $refresh . "'>\r\n"; |
c9a520e2 ER |
660 | } |
661 | ?> | |
1c1c23da | 662 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> |
ac01d3f9 | 663 | - <link href="include/main.css" type="text/css" rel="stylesheet"> |
c9a520e2 ER |
664 | - <link href="images/favicon.ico" rel="shortcut icon"/> |
665 | - <script type="text/javascript" src="include/layout.js"></script> | |
666 | - <script type="text/javascript" src="include/treeview/ua.js"></script> | |
667 | - <script type="text/javascript" src="include/treeview/ftiens4.js"></script> | |
668 | - <script type="text/javascript" src="include/jscalendar/calendar.js"></script> | |
669 | - <script type="text/javascript" src="include/jscalendar/lang/calendar-en.js"></script> | |
670 | - <script type="text/javascript" src="include/jscalendar/calendar-setup.js"></script> | |
ac01d3f9 | 671 | + <link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet"> |
c9a520e2 ER |
672 | + <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/> |
673 | + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script> | |
674 | + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ua.js"></script> | |
675 | + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ftiens4.js"></script> | |
676 | + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar.js"></script> | |
677 | + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/lang/calendar-en.js"></script> | |
678 | + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar-setup.js"></script> | |
679 | + <?php api_plugin_hook('page_head'); ?> | |
680 | </head> | |
681 | ||
ac01d3f9 | 682 | -<body> |
c9a520e2 | 683 | +<?php if ($oper_mode == OPER_MODE_NATIVE) {?> |
ac01d3f9 | 684 | +<body <?php print api_plugin_hook_function("body_style", "");?>> |
c9a520e2 ER |
685 | <a name='page_top'></a> |
686 | +<?php }else{?> | |
ac01d3f9 | 687 | +<body <?php print api_plugin_hook_function("body_style", "");?>> |
c9a520e2 | 688 | +<?php }?> |
ac01d3f9 AZ |
689 | + |
690 | <table style="width:100%;height:100%;" cellspacing="0" cellpadding="0"> | |
c9a520e2 | 691 | +<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?> |
ac01d3f9 | 692 | <tr style="height:25px;" bgcolor="#a9a9a9" class="noprint"> |
c9a520e2 ER |
693 | <td colspan="2" valign="bottom" nowrap> |
694 | <table width="100%" cellspacing="0" cellpadding="0"> | |
695 | - <tr style="background: transparent url('images/cacti_backdrop2.gif') no-repeat center right;"> | |
696 | + <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop2.gif') no-repeat center right;"> | |
697 | <td id="tabs" nowrap> | |
1c1c23da | 698 | - <?php if ($show_console_tab == true) {?><a href="index.php"><img src="images/tab_console.gif" alt="Console" align="absmiddle" border="0"></a><?php }?><a href="graph_view.php"><img src="images/tab_graphs<?php if ((substr(basename($_SERVER["PHP_SELF"]),0,5) == "graph") || (basename($_SERVER["PHP_SELF"]) == "graph_settings.php")) { print "_down"; } print ".gif";?>" alt="Graphs" align="absmiddle" border="0"></a> |
c9a520e2 ER |
699 | + <?php if ($show_console_tab == true) {?><a href="<?php echo $config['url_path']; ?>index.php"><img src="<?php echo $config['url_path']; ?>images/tab_console.gif" alt="Console" align="absmiddle" border="0"></a><?php }?><a href="<?php echo $config['url_path']; ?>graph_view.php"><img src="<?php echo $config['url_path']; ?>images/tab_graphs<?php if ((substr(basename($_SERVER["PHP_SELF"]),0,5) == "graph") || (basename($_SERVER["PHP_SELF"]) == "graph_settings.php")) { print "_down"; } print ".gif";?>" alt="Graphs" align="absmiddle" border="0"></a><?php |
700 | + api_plugin_hook('top_graph_header_tabs'); | |
701 | + ?> | |
702 | </td> | |
703 | <td id="gtabs" align="right" nowrap> | |
1c1c23da | 704 | - <?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["graph_settings"] == "on")) { print '<a href="graph_settings.php"><img src="images/tab_settings'; if (basename($_SERVER["PHP_SELF"]) == "graph_settings.php") { print "_down"; } print '.gif" border="0" alt="Settings" align="absmiddle"></a>';}?> <?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_tree"] == "on")) {?><a href="<?php print htmlspecialchars("graph_view.php?action=tree");?>"><img src="images/tab_mode_tree<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "tree") { print "_down"; }?>.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_list"] == "on")) {?><a href="graph_view.php?action=list"><img src="images/tab_mode_list<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "list") { print "_down"; }?>.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_preview"] == "on")) {?><a href="graph_view.php?action=preview"><img src="images/tab_mode_preview<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?> <br> |
ac01d3f9 | 705 | + <?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["graph_settings"] == "on")) { print '<a href="' . $config['url_path'] . 'graph_settings.php"><img src="' . $config['url_path'] . 'images/tab_settings'; if (basename($_SERVER["PHP_SELF"]) == "graph_settings.php") { print "_down"; } print '.gif" border="0" alt="Settings" align="absmiddle"></a>';}?> <?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_tree"] == "on")) {?><a href="<?php print htmlspecialchars($config['url_path'] . "graph_view.php?action=tree");?>"><img src="<?php echo $config['url_path']; ?>images/tab_mode_tree<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "tree") { print "_down"; }?>.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_list"] == "on")) {?><a href="<?php print htmlspecialchars($config['url_path'] . "graph_view.php?action=list");?>"><img src="<?php echo $config['url_path']; ?>images/tab_mode_list<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "list") { print "_down"; }?>.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_preview"] == "on")) {?><a href="<?php print htmlspecialchars($config['url_path'] . "graph_view.php?action=preview");?>"><img src="<?php echo $config['url_path']; ?>images/tab_mode_preview<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?> <br> |
c9a520e2 ER |
706 | </td> |
707 | </tr> | |
708 | </table> | |
1c1c23da | 709 | @@ -94,7 +111,7 @@ |
c9a520e2 | 710 | </tr> |
ac01d3f9 | 711 | <tr style="height:2px;" bgcolor="#183c8f" class="noprint"> |
c9a520e2 | 712 | <td colspan="2"> |
ac01d3f9 AZ |
713 | - <img src="images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br> |
714 | + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br> | |
c9a520e2 ER |
715 | </td> |
716 | </tr> | |
ac01d3f9 | 717 | <tr style="height:5px;" bgcolor="#e9e9e9" class="noprint"> |
1c1c23da | 718 | @@ -106,7 +123,7 @@ |
c9a520e2 ER |
719 | </td> |
720 | <td align="right"> | |
721 | <?php if ((isset($_SESSION["sess_user_id"])) && ($using_guest_account == false)) { ?> | |
722 | - Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="logout.php">Logout</a>) | |
723 | + Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="<?php echo $config['url_path']; ?>logout.php">Logout</a>) | |
724 | <?php } ?> | |
725 | </td> | |
726 | </tr> | |
1c1c23da | 727 | @@ -114,10 +131,10 @@ |
c9a520e2 ER |
728 | </td> |
729 | </tr> | |
730 | <tr class="noprint"> | |
ac01d3f9 AZ |
731 | - <td bgcolor="#efefef" colspan="1" style="height:8px;background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;"> |
732 | - <img src="images/transparent_line.gif" width="<?php print htmlspecialchars(read_graph_config_option("default_dual_pane_width"));?>" style="height:2px;" border="0"><br> | |
733 | + <td bgcolor="#efefef" colspan="1" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;"> | |
734 | + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="<?php print htmlspecialchars(read_graph_config_option("default_dual_pane_width"));?>" style="height:2px;" border="0"><br> | |
c9a520e2 | 735 | </td> |
ac01d3f9 AZ |
736 | - <td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(images/shadow.gif); background-repeat: repeat-x;"> |
737 | + <td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;"> | |
c9a520e2 ER |
738 | |
739 | </td> | |
740 | </tr> | |
1c1c23da | 741 | @@ -143,6 +160,8 @@ |
c9a520e2 ER |
742 | </td> |
743 | </tr> | |
ac01d3f9 AZ |
744 | <?php } |
745 | + } | |
746 | + global $graph_views; | |
747 | load_current_session_value("action", "sess_cacti_graph_action", $graph_views[read_graph_config_option("default_tree_view_mode")]); | |
748 | ?> | |
c9a520e2 | 749 | <tr> |
1c1c23da SP |
750 | diff -Naur cacti-0.8.7g-old/include/top_header.php cacti-0.8.7g/include/top_header.php |
751 | --- cacti-0.8.7g-old/include/top_header.php 2010-07-09 18:33:46.000000000 -0400 | |
752 | +++ cacti-0.8.7g/include/top_header.php 2010-07-09 18:34:11.000000000 -0400 | |
753 | @@ -22,38 +22,53 @@ | |
c9a520e2 ER |
754 | +-------------------------------------------------------------------------+ |
755 | */ | |
756 | ||
757 | -global $colors; | |
758 | +global $colors, $config; | |
759 | + | |
760 | +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE); | |
761 | +if ($oper_mode == OPER_MODE_RESKIN) { | |
762 | + return; | |
763 | +} | |
764 | + | |
ac01d3f9 | 765 | +$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title")); |
c9a520e2 ER |
766 | + |
767 | ?> | |
ac01d3f9 | 768 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
c9a520e2 ER |
769 | <html> |
770 | <head> | |
ac01d3f9 AZ |
771 | - <title><?php echo draw_navigation_text("title");?></title> |
772 | - <link href="include/main.css" type="text/css" rel="stylesheet"> | |
c9a520e2 | 773 | - <link href="images/favicon.ico" rel="shortcut icon"/> |
c9a520e2 | 774 | + <title><?php echo $page_title; ?></title> |
ac01d3f9 | 775 | + <link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet"> |
1c1c23da SP |
776 | + <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"> |
777 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
778 | - <script type="text/javascript" src="include/layout.js"></script> | |
c9a520e2 ER |
779 | + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script> |
780 | <?php if (isset($refresh)) { | |
781 | print "<meta http-equiv=refresh content=\"" . $refresh["seconds"] . "; url='" . $refresh["page"] . "'\">"; | |
782 | - }?> | |
783 | + } | |
784 | + api_plugin_hook('page_head'); ?> | |
c9a520e2 ER |
785 | </head> |
786 | ||
1c1c23da | 787 | -<body style="background-image:url('images/left_border.gif');background-repeat:repeat-y;"> |
c9a520e2 | 788 | +<?php if ($oper_mode == OPER_MODE_NATIVE) {?> |
1c1c23da | 789 | +<body style="background-image:url('<?php print $config['url_path'];?>images/left_border.gif');background-repeat:repeat-y;" <?php print api_plugin_hook_function("body_style", "");?>> |
c9a520e2 | 790 | +<?php }else{?> |
1c1c23da | 791 | +<body style="background-image:url('<?php print $config['url_path'];?>images/left_border.gif');background-repeat:repeat-y;" <?php print api_plugin_hook_function("body_style", "");?>> |
c9a520e2 ER |
792 | +<?php }?> |
793 | ||
794 | <table width="100%" cellspacing="0" cellpadding="0"> | |
795 | +<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?> | |
ac01d3f9 | 796 | <tr style="height:1px;" bgcolor="#a9a9a9"> |
c9a520e2 ER |
797 | <td valign="bottom" colspan="3" nowrap> |
798 | <table width="100%" cellspacing="0" cellpadding="0"> | |
799 | - <tr style="background: transparent url('images/cacti_backdrop.gif') no-repeat center right;"> | |
800 | + <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop.gif') no-repeat center right;"> | |
801 | <td id="tabs" valign="bottom"> | |
1c1c23da | 802 | - <a href="index.php"><img src="images/tab_console_down.gif" alt="Console" align="absmiddle" border="0"></a><a href="graph_view.php"><img src="images/tab_graphs.gif" alt="Graphs" align="absmiddle" border="0"></a> |
c9a520e2 ER |
803 | - </td> |
804 | + <a href="<?php echo $config['url_path']; ?>index.php"><img src="<?php echo $config['url_path']; ?>images/tab_console_down.gif" alt="Console" align="absmiddle" border="0"></a><a href="<?php echo $config['url_path']; ?>graph_view.php"><img src="<?php echo $config['url_path']; ?>images/tab_graphs.gif" alt="Graphs" align="absmiddle" border="0"></a><?php | |
805 | + api_plugin_hook('top_header_tabs'); | |
806 | + ?></td> | |
807 | </tr> | |
808 | </table> | |
809 | </td> | |
810 | </tr> | |
ac01d3f9 | 811 | <tr style="height:2px;" bgcolor="#183c8f"> |
c9a520e2 | 812 | <td colspan="3"> |
ac01d3f9 AZ |
813 | - <img src="images/transparent_line.gif" style="height:2px;" border="0"><br> |
814 | + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;" border="0"><br> | |
c9a520e2 ER |
815 | </td> |
816 | </tr> | |
ac01d3f9 | 817 | <tr style="height:5px;" bgcolor="#e9e9e9"> |
1c1c23da | 818 | @@ -65,7 +80,7 @@ |
c9a520e2 ER |
819 | </td> |
820 | <td align="right"> | |
821 | <?php if (read_config_option("auth_method") != 0) { ?> | |
822 | - Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="logout.php">Logout</a>) | |
823 | + Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="<?php echo $config['url_path']; ?>logout.php">Logout</a>) | |
824 | <?php } ?> | |
825 | </td> | |
826 | </tr> | |
1c1c23da | 827 | @@ -73,10 +88,10 @@ |
c9a520e2 ER |
828 | </td> |
829 | </tr> | |
830 | <tr> | |
ac01d3f9 AZ |
831 | - <td bgcolor="#f5f5f5" colspan="1" style="height:8px;width:135px;background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;"> |
832 | - <img src="images/transparent_line.gif" style="height:2px;width:135px;" border="0"><br> | |
833 | + <td bgcolor="#f5f5f5" colspan="1" style="height:8px;width:135px;background-image: url(<?php echo $config['url_path']; ?>images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;"> | |
834 | + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;width:135px;" border="0"><br> | |
835 | </td> | |
836 | - <td colspan="2" style="height:8px;background-image: url(images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff"> | |
837 | + <td colspan="2" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff"> | |
c9a520e2 ER |
838 | |
839 | </td> | |
840 | </tr> | |
1c1c23da | 841 | @@ -86,9 +101,12 @@ |
c9a520e2 ER |
842 | <?php draw_menu();?> |
843 | </table> | |
844 | ||
ac01d3f9 | 845 | - <img src="images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br> |
c9a520e2 | 846 | - <p align="center"><a href='about.php'><img src="images/cacti_logo.gif" border="0"></a></p> |
ac01d3f9 AZ |
847 | - <img src="images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br> |
848 | + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br> | |
c9a520e2 | 849 | + <p align="center"><a href='<?php echo $config['url_path']; ?>about.php'><img src="<?php echo $config['url_path']; ?>images/cacti_logo.gif" border="0"></a></p> |
ac01d3f9 | 850 | + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br> |
c9a520e2 | 851 | </td> |
ac01d3f9 | 852 | <td width="100%" colspan="2" valign="top" style="padding: 5px; border-right: #aaaaaa 1px solid;"><?php display_output_messages();?><div style='position:relative;' id='main'> |
c9a520e2 ER |
853 | - |
854 | +<?php }else{ ?> | |
855 | + <tr> | |
856 | + <td width="100%" valign="top"><?php display_output_messages();?> | |
857 | +<?php } ?> | |
1c1c23da SP |
858 | diff -Naur cacti-0.8.7g-old/index.php cacti-0.8.7g/index.php |
859 | --- cacti-0.8.7g-old/index.php 2010-07-09 18:33:46.000000000 -0400 | |
860 | +++ cacti-0.8.7g/index.php 2010-07-09 18:34:11.000000000 -0400 | |
c9a520e2 ER |
861 | @@ -25,6 +25,8 @@ |
862 | include("./include/auth.php"); | |
863 | include("./include/top_header.php"); | |
864 | ||
865 | +api_plugin_hook('console_before'); | |
866 | + | |
867 | ?> | |
868 | <table width="100%" align="center"> | |
869 | <tr> | |
870 | @@ -46,6 +48,8 @@ | |
871 | ||
872 | <?php | |
873 | ||
874 | +api_plugin_hook('console_after'); | |
875 | + | |
876 | include("./include/bottom_footer.php"); | |
877 | ||
878 | ?> | |
1c1c23da SP |
879 | diff -Naur cacti-0.8.7g-old/lib/api_device.php cacti-0.8.7g/lib/api_device.php |
880 | --- cacti-0.8.7g-old/lib/api_device.php 2010-07-09 18:33:46.000000000 -0400 | |
881 | +++ cacti-0.8.7g/lib/api_device.php 2010-07-09 18:34:11.000000000 -0400 | |
c9a520e2 ER |
882 | @@ -137,6 +137,8 @@ |
883 | $save["ping_retries"] = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3); | |
884 | $save["max_oids"] = form_input_validate($max_oids, "max_oids", "^[0-9]+$", true, 3); | |
885 | ||
886 | + $save = api_plugin_hook_function('api_device_save', $save); | |
887 | + | |
888 | $host_id = 0; | |
889 | ||
890 | if (!is_error_message()) { | |
1c1c23da SP |
891 | diff -Naur cacti-0.8.7g-old/lib/auth.php cacti-0.8.7g/lib/auth.php |
892 | --- cacti-0.8.7g-old/lib/auth.php 2010-07-09 18:33:46.000000000 -0400 | |
893 | +++ cacti-0.8.7g/lib/auth.php 2010-07-09 18:34:11.000000000 -0400 | |
ac01d3f9 | 894 | @@ -121,8 +121,9 @@ |
c9a520e2 ER |
895 | } |
896 | } | |
897 | ||
ac01d3f9 | 898 | - return true; |
c9a520e2 | 899 | + api_plugin_hook_function('copy_user', array('template_id' => $template_id, 'new_id' => $new_id)); |
c9a520e2 | 900 | |
ac01d3f9 | 901 | + return true; |
c9a520e2 | 902 | } |
ac01d3f9 AZ |
903 | |
904 | ||
905 | @@ -152,6 +153,7 @@ | |
c9a520e2 ER |
906 | db_execute("delete from settings_graphs where user_id=" . $user_id); |
907 | db_execute("delete from settings_tree where user_id=" . $user_id); | |
908 | ||
909 | + api_plugin_hook_function('user_remove', $user_id); | |
910 | } | |
911 | ||
ac01d3f9 | 912 | /* user_disable - disable a user account |
1c1c23da SP |
913 | diff -Naur cacti-0.8.7g-old/lib/functions.php cacti-0.8.7g/lib/functions.php |
914 | --- cacti-0.8.7g-old/lib/functions.php 2010-07-09 18:33:46.000000000 -0400 | |
915 | +++ cacti-0.8.7g/lib/functions.php 2010-07-09 18:34:11.000000000 -0400 | |
916 | @@ -1689,6 +1689,8 @@ | |
ac01d3f9 AZ |
917 | @arg $type - (string) Either 'url' or 'title' |
918 | @returns (string> Either the navigation text or title */ | |
919 | function draw_navigation_text($type = "url") { | |
c9a520e2 | 920 | + global $config; |
ac01d3f9 | 921 | + |
c9a520e2 ER |
922 | $nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : array()); |
923 | ||
924 | $nav = array( | |
1c1c23da | 925 | @@ -1701,8 +1703,8 @@ |
c9a520e2 ER |
926 | "graph.php:zoom" => array("title" => "Zoom", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"), |
927 | "graph.php:properties" => array("title" => "Properties", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"), | |
928 | "graph_settings.php:" => array("title" => "Settings", "mapping" => "graph_view.php:", "url" => "graph_settings.php", "level" => "1"), | |
929 | - "index.php:" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"), | |
930 | - "index.php:login" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"), | |
931 | + "index.php:" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"), | |
932 | + "index.php:login" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"), | |
933 | "graphs.php:" => array("title" => "Graph Management", "mapping" => "index.php:", "url" => "graphs.php", "level" => "1"), | |
934 | "graphs.php:graph_edit" => array("title" => "(Edit)", "mapping" => "index.php:,graphs.php:", "url" => "", "level" => "2"), | |
935 | "graphs.php:graph_diff" => array("title" => "Change Graph Template", "mapping" => "index.php:,graphs.php:,graphs.php:graph_edit", "url" => "", "level" => "3"), | |
1c1c23da | 936 | @@ -1780,6 +1782,8 @@ |
c9a520e2 ER |
937 | "templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"), |
938 | ); | |
939 | ||
940 | + $nav = api_plugin_hook_function('draw_navigation_text', $nav); | |
941 | + | |
942 | $current_page = basename($_SERVER["PHP_SELF"]); | |
943 | ||
944 | input_validate_input_regex(get_request_var_request("action"), "^([a-zA-Z0-9_-]+)$"); | |
1c1c23da SP |
945 | diff -Naur cacti-0.8.7g-old/lib/html_form.php cacti-0.8.7g/lib/html_form.php |
946 | --- cacti-0.8.7g-old/lib/html_form.php 2010-07-09 18:33:46.000000000 -0400 | |
947 | +++ cacti-0.8.7g/lib/html_form.php 2010-07-09 18:34:11.000000000 -0400 | |
948 | @@ -722,11 +722,13 @@ | |
949 | on a confirmation form | |
950 | @arg $cancel_url - the url to go to when the user clicks 'cancel' | |
951 | @arg $action_url - the url to go to when the user clicks 'delete' */ | |
952 | -function form_confirm_buttons($action_url, $cancel_url) { ?> | |
953 | +function form_confirm_buttons($action_url, $cancel_url) { | |
954 | + global $config; | |
955 | + ?> | |
c9a520e2 ER |
956 | <tr> |
957 | <td bgcolor="#E1E1E1"> | |
ac01d3f9 AZ |
958 | - <input type='button' onClick='cactiReturnTo("<?php print $cancel_url;?>")' value='Cancel'> |
959 | - <input type='submit' onClick='cactiReturnTo("<?php print $action_url;?>&confirm=true")' value='Delete'> | |
960 | + <input type='button' onClick='cactiReturnTo("<?php print $config['url_path'] . $cancel_url;?>")' value='Cancel'> | |
961 | + <input type='submit' onClick='cactiReturnTo("<?php print $config['url_path'] . $action_url;?>&confirm=true")' value='Delete'> | |
c9a520e2 ER |
962 | </td> |
963 | </tr> | |
964 | <?php } | |
1c1c23da SP |
965 | diff -Naur cacti-0.8.7g-old/lib/html.php cacti-0.8.7g/lib/html.php |
966 | --- cacti-0.8.7g-old/lib/html.php 2010-07-09 18:33:46.000000000 -0400 | |
967 | +++ cacti-0.8.7g/lib/html.php 2010-07-09 18:34:11.000000000 -0400 | |
ac01d3f9 | 968 | @@ -144,14 +144,15 @@ |
c9a520e2 ER |
969 | <table align='center' cellpadding='0'> |
970 | <tr> | |
971 | <td align='center'> | |
1c1c23da SP |
972 | - <div style="min-height: <?php echo (1.6 * $graph["height"]) . "px"?>;"><a href='<?php print htmlspecialchars("graph.php?action=view&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=all");?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0" . (($extra_url_args == "") ? "" : "&$extra_url_args"));?>' border='0' alt='<?php print htmlspecialchars($graph["title_cache"]);?>'></a></div> |
973 | + <div style="min-height: <?php echo (1.6 * $graph["height"]) . "px"?>;"><a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=view&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=all");?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print htmlspecialchars($config['url_path'] . "graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0" . (($extra_url_args == "") ? "" : "&$extra_url_args"));?>' border='0' alt='<?php print htmlspecialchars($graph["title_cache"]);?>'></a></div> | |
974 | <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?> | |
c9a520e2 ER |
975 | </td> |
976 | <td valign='top' style='align: left; padding: 3px;' class='noprint'> | |
ac01d3f9 AZ |
977 | - <a href='<?php print htmlspecialchars("graph.php?action=zoom&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&". $extra_url_args);?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br> |
978 | - <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br> | |
979 | - <a href='<?php print htmlspecialchars("graph.php?action=properties&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br> | |
c9a520e2 | 980 | - <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br> |
1c1c23da SP |
981 | + <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=zoom&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&". $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br> |
982 | + <a href='<?php print htmlspecialchars($config['url_path'] . "graph_xport.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br> | |
983 | + <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=properties&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br> | |
c9a520e2 ER |
984 | + <?php api_plugin_hook('graph_buttons', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => 'view')); ?> |
985 | + <a href='#page_top'><img src='<?php print $config['url_path']; ?>images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br> | |
986 | </td> | |
987 | </tr> | |
988 | </table> | |
ac01d3f9 | 989 | @@ -177,6 +178,7 @@ |
c9a520e2 ER |
990 | @arg $extra_url_args - extra arguments to append to the url |
991 | @arg $header - html to use as a header */ | |
992 | function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") { | |
993 | + global $config; | |
994 | $i = 0; $k = 0; $j = 0; | |
995 | ||
996 | $num_graphs = sizeof($graph_array); | |
ac01d3f9 | 997 | @@ -268,14 +270,15 @@ |
c9a520e2 ER |
998 | <table align='center' cellpadding='0'> |
999 | <tr> | |
1000 | <td align='center'> | |
1c1c23da SP |
1001 | - <div style="min-height: <?php echo (1.6 * read_graph_config_option("default_height")) . "px"?>;"><a href='<?php print htmlspecialchars("graph.php?action=view&rra_id=all&local_graph_id=" . $graph["local_graph_id"]);?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width") . "&graph_nolegend=true" . (($extra_url_args == "") ? "" : "&$extra_url_args"));?>' border='0' alt='<?php print htmlspecialchars($graph["title_cache"]);?>'></a></div> |
1002 | + <div style="min-height: <?php echo (1.6 * read_graph_config_option("default_height")) . "px"?>;"><a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=view&rra_id=all&local_graph_id=" . $graph["local_graph_id"]);?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print htmlspecialchars($config["url_path"] . "graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width") . "&graph_nolegend=true" . (($extra_url_args == "") ? "" : "&$extra_url_args"));?>' border='0' alt='<?php print htmlspecialchars($graph["title_cache"]);?>'></a></div> | |
1003 | <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?> | |
c9a520e2 ER |
1004 | </td> |
1005 | <td valign='top' style='align: left; padding: 3px;'> | |
ac01d3f9 AZ |
1006 | - <a href='<?php print htmlspecialchars("graph.php?action=zoom&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br> |
1007 | - <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br> | |
1008 | - <a href='<?php print htmlspecialchars("graph.php?action=properties&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br> | |
1009 | - <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br> | |
1c1c23da SP |
1010 | + <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=zoom&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br> |
1011 | + <a href='<?php print htmlspecialchars($config['url_path'] . "graph_xport.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br> | |
1012 | + <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=properties&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br> | |
c9a520e2 | 1013 | + <?php api_plugin_hook('graph_buttons_thumbnails', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => '')); ?> |
ac01d3f9 | 1014 | + <a href='#page_top'><img src='<?php print $config['url_path'] . "images/graph_page_top.gif";?>' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br> |
c9a520e2 ER |
1015 | </td> |
1016 | </tr> | |
ac01d3f9 | 1017 | </table> |
1c1c23da SP |
1018 | @@ -638,9 +641,9 @@ |
1019 | print "<td style='$this_row_style'>" . $item["hex"] . "</td>\n"; | |
1020 | ||
1021 | if ($disable_controls == false) { | |
1022 | - print "<td><a href='" . htmlspecialchars("$filename?action=item_movedown&id=" . $item["id"] . "&$url_data") . "'><img src='images/move_down.gif' border='0' alt='Move Down'></a> | |
1023 | - <a href='" . htmlspecialchars("$filename?action=item_moveup&id=" . $item["id"] . "&$url_data") . "'><img src='images/move_up.gif' border='0' alt='Move Up'></a></td>\n"; | |
1024 | - print "<td align='right'><a href='" . htmlspecialchars("$filename?action=item_remove&id=" . $item["id"] . "&$url_data") . "'><img src='images/delete_icon.gif' style='height:10px;width:10px;' border='0' alt='Delete'></a></td>\n"; | |
1025 | + print "<td><a href='" . htmlspecialchars("$filename?action=item_movedown&id=" . $item["id"] . "&$url_data") . "'><img src='" . $config['url_path'] . "images/move_down.gif' border='0' alt='Move Down'></a> | |
1026 | + <a href='" . htmlspecialchars("$filename?action=item_moveup&id=" . $item["id"] . "&$url_data") . "'><img src='" . $config['url_path'] . "images/move_up.gif' border='0' alt='Move Up'></a></td>\n"; | |
1027 | + print "<td align='right'><a href='" . htmlspecialchars("$filename?action=item_remove&id=" . $item["id"] . "&$url_data") . "'><img src='" . $config['url_path'] . "images/delete_icon.gif' style='height:10px;width:10px;' border='0' alt='Delete'></a></td>\n"; | |
1028 | } | |
1029 | ||
1030 | print "</tr>"; | |
ac01d3f9 | 1031 | @@ -706,6 +709,8 @@ |
c9a520e2 ER |
1032 | } |
1033 | ||
1034 | while (list($item_sub_url, $item_sub_title) = each($item_title)) { | |
1035 | + $item_sub_url = $config['url_path'] . $item_sub_url; | |
1036 | + | |
1037 | /* indent sub-items */ | |
1038 | if ($i > 0) { | |
1039 | $prepend_string = "--- "; | |
ac01d3f9 | 1040 | @@ -715,7 +720,7 @@ |
c9a520e2 ER |
1041 | |
1042 | /* do not put a line between each sub-item */ | |
1043 | if (($i == 0) || ($draw_sub_items == false)) { | |
1044 | - $background = "images/menu_line.gif"; | |
1045 | + $background = $config['url_path'] . "images/menu_line.gif"; | |
1046 | }else{ | |
1047 | $background = ""; | |
1048 | } | |
ac01d3f9 | 1049 | @@ -744,17 +749,18 @@ |
c9a520e2 | 1050 | }else{ |
ac01d3f9 | 1051 | if ($current_realm_id == -1 || (isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) { |
c9a520e2 ER |
1052 | /* draw normal (non sub-item) menu item */ |
1053 | + $item_url = $config['url_path'] . $item_url; | |
1054 | if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) { | |
ac01d3f9 AZ |
1055 | - print "<tr><td class='textMenuItemSelected' style='background-image:url(\"images/menu_line.gif\");'><strong><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></strong></td></tr>\n"; |
1056 | + print "<tr><td class='textMenuItemSelected' style='background-image:url(\"" . $config['url_path'] . "images/menu_line.gif\");'><strong><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></strong></td></tr>\n"; | |
c9a520e2 | 1057 | }else{ |
ac01d3f9 AZ |
1058 | - print "<tr><td class='textMenuItem' style='background-image:url(\"images/menu_line.gif\");'><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></td></tr>\n"; |
1059 | + print "<tr><td class='textMenuItem' style='background-image:url(\"" . $config['url_path'] . "images/menu_line.gif\");'><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></td></tr>\n"; | |
c9a520e2 ER |
1060 | } |
1061 | } | |
1062 | } | |
1063 | } | |
1064 | } | |
1065 | ||
ac01d3f9 AZ |
1066 | - print "<tr><td class='textMenuItem' style='background-image:url(\"images/menu_line.gif\");'></td></tr>\n"; |
1067 | + print "<tr><td class='textMenuItem' style='background-image:url(\"" . $config['url_path'] . "images/menu_line.gif\");'></td></tr>\n"; | |
c9a520e2 ER |
1068 | |
1069 | print "</table></td></tr>"; | |
1070 | } | |
ac01d3f9 | 1071 | @@ -764,11 +770,12 @@ |
c9a520e2 ER |
1072 | @arg $actions_array - an array that contains a list of possible actions. this array should |
1073 | be compatible with the form_dropdown() function */ | |
1074 | function draw_actions_dropdown($actions_array) { | |
1075 | + global $config; | |
1076 | ?> | |
1077 | <table align='center' width='100%'> | |
1078 | <tr> | |
1079 | <td width='1' valign='top'> | |
ac01d3f9 | 1080 | - <img src='images/arrow.gif' alt=''> |
1c1c23da | 1081 | + <img src='<?php echo $config['url_path']; ?>images/arrow.gif' alt='' align='middle'> |
c9a520e2 ER |
1082 | </td> |
1083 | <td align='right'> | |
1084 | Choose an action: | |
1c1c23da SP |
1085 | diff -Naur cacti-0.8.7g-old/lib/plugins.php cacti-0.8.7g/lib/plugins.php |
1086 | --- cacti-0.8.7g-old/lib/plugins.php 1969-12-31 19:00:00.000000000 -0500 | |
1087 | +++ cacti-0.8.7g/lib/plugins.php 2010-07-09 18:34:11.000000000 -0400 | |
1088 | @@ -0,0 +1,476 @@ | |
c9a520e2 ER |
1089 | +<?php |
1090 | + | |
1091 | + | |
1092 | + | |
1093 | +function do_hook ($name) { | |
1094 | + $data = func_get_args(); | |
1095 | + $data = api_plugin_hook ($name, $data); | |
1096 | + return $data; | |
1097 | +} | |
1098 | + | |
1099 | +function do_hook_function($name,$parm=NULL) { | |
1100 | + return api_plugin_hook_function ($name, $parm); | |
1101 | +} | |
1102 | + | |
1103 | +function api_user_realm_auth ($filename = '') { | |
1104 | + return api_plugin_user_realm_auth ($filename); | |
1105 | +} | |
1106 | + | |
1107 | +/** | |
1108 | + * This function executes a hook. | |
1109 | + * @param string $name Name of hook to fire | |
1110 | + * @return mixed $data | |
1111 | + */ | |
1112 | +function api_plugin_hook ($name) { | |
1c1c23da | 1113 | + global $config, $plugin_hooks, $plugins_system; |
c9a520e2 ER |
1114 | + $data = func_get_args(); |
1115 | + $ret = ''; | |
1116 | + $p = array(); | |
1117 | + | |
1c1c23da SP |
1118 | + $ps_where = ''; |
1119 | + if (sizeof($plugins_system)) { | |
1120 | + foreach($plugins_system as $plugin) { | |
1121 | + $ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin; | |
1122 | + } | |
1123 | + $ps_where .= "')"; | |
1124 | + } | |
1125 | + | |
1126 | + /* order the plugin functions by system first, then followed by order */ | |
1127 | + $result = db_fetch_assoc("SELECT 1 AS id, ph.name, ph.file, ph.function | |
1128 | + FROM plugin_hooks AS ph | |
1129 | + LEFT JOIN plugin_config AS pc | |
1130 | + ON pc.directory=ph.name | |
1131 | + WHERE ph.status = 1 AND hook = '$name' | |
1132 | + AND ph.name IN $ps_where | |
1133 | + UNION | |
1134 | + SELECT pc.id, ph.name, ph.file, ph.function | |
1135 | + FROM plugin_hooks AS ph | |
1136 | + LEFT JOIN plugin_config AS pc | |
1137 | + ON pc.directory=ph.name | |
1138 | + WHERE ph.status = 1 AND hook = '$name' | |
1139 | + AND ph.name NOT IN $ps_where | |
1140 | + ORDER BY id ASC", true); | |
1141 | + | |
c9a520e2 ER |
1142 | + if (count($result)) { |
1143 | + foreach ($result as $hdata) { | |
1144 | + $p[] = $hdata['name']; | |
1145 | + if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) { | |
1146 | + include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']); | |
1147 | + } | |
1148 | + $function = $hdata['function']; | |
1149 | + if (function_exists($function)) { | |
1150 | + $function($data); | |
1151 | + } | |
1152 | + } | |
1153 | + } | |
1154 | + | |
1155 | + if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) { | |
1156 | + foreach ($plugin_hooks[$name] as $pname => $function) { | |
1157 | + if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) { | |
1158 | + $function($data); | |
1159 | + } | |
1160 | + } | |
1161 | + } | |
1162 | + | |
1163 | + /* Variable-length argument lists have a slight problem when */ | |
1164 | + /* passing values by reference. Pity. This is a workaround. */ | |
1165 | + return $data; | |
1166 | +} | |
1167 | + | |
1168 | +function api_plugin_hook_function ($name, $parm=NULL) { | |
1c1c23da | 1169 | + global $config, $plugin_hooks, $plugins_system; |
c9a520e2 ER |
1170 | + $ret = $parm; |
1171 | + $p = array(); | |
1c1c23da SP |
1172 | + $ps_where = ''; |
1173 | + | |
1174 | + if (sizeof($plugins_system)) { | |
1175 | + foreach($plugins_system as $plugin) { | |
1176 | + $ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin; | |
1177 | + } | |
1178 | + $ps_where .= "')"; | |
1179 | + } | |
1180 | + | |
1181 | + /* order the plugin functions by system first, then followed by order */ | |
1182 | + $result = db_fetch_assoc("SELECT 1 AS id, ph.name, ph.file, ph.function | |
1183 | + FROM plugin_hooks AS ph | |
1184 | + LEFT JOIN plugin_config AS pc | |
1185 | + ON pc.directory=ph.name | |
1186 | + WHERE ph.status = 1 AND hook = '$name' | |
1187 | + AND ph.name IN $ps_where | |
1188 | + UNION | |
1189 | + SELECT pc.id, ph.name, ph.file, ph.function | |
1190 | + FROM plugin_hooks AS ph | |
1191 | + LEFT JOIN plugin_config AS pc | |
1192 | + ON pc.directory=ph.name | |
1193 | + WHERE ph.status = 1 AND hook = '$name' | |
1194 | + AND ph.name NOT IN $ps_where | |
1195 | + ORDER BY id ASC", true); | |
c9a520e2 ER |
1196 | + |
1197 | + if (count($result)) { | |
1198 | + foreach ($result as $hdata) { | |
1199 | + $p[] = $hdata['name']; | |
1200 | + if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) { | |
1201 | + include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']); | |
1202 | + } | |
1203 | + $function = $hdata['function']; | |
1204 | + if (function_exists($function)) { | |
1205 | + $ret = $function($ret); | |
1206 | + } | |
1207 | + } | |
1208 | + } | |
1209 | + | |
1210 | + if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) { | |
1211 | + foreach ($plugin_hooks[$name] as $pname => $function) { | |
1212 | + if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) { | |
1213 | + $ret = $function($ret); | |
1214 | + } | |
1215 | + } | |
1216 | + } | |
1217 | + | |
1218 | + /* Variable-length argument lists have a slight problem when */ | |
1219 | + /* passing values by reference. Pity. This is a workaround. */ | |
1220 | + return $ret; | |
1221 | +} | |
1222 | + | |
1223 | +function api_plugin_db_table_create ($plugin, $table, $data) { | |
1224 | + global $config, $database_default; | |
1225 | + include_once($config["library_path"] . "/database.php"); | |
1226 | + | |
1227 | + $result = db_fetch_assoc("show tables from `" . $database_default . "`") or die (mysql_error()); | |
1228 | + $tables = array(); | |
1229 | + foreach($result as $index => $arr) { | |
1230 | + foreach ($arr as $t) { | |
1231 | + $tables[] = $t; | |
1232 | + } | |
1233 | + } | |
1234 | + if (!in_array($table, $tables)) { | |
1235 | + $c = 0; | |
1236 | + $sql = 'CREATE TABLE `' . $table . "` (\n"; | |
1237 | + foreach ($data['columns'] as $column) { | |
1238 | + if (isset($column['name'])) { | |
1239 | + if ($c > 0) | |
1240 | + $sql .= ",\n"; | |
1241 | + $sql .= '`' . $column['name'] . '`'; | |
1242 | + if (isset($column['type'])) | |
1243 | + $sql .= ' ' . $column['type']; | |
1244 | + if (isset($column['unsigned'])) | |
1245 | + $sql .= ' unsigned'; | |
1246 | + if (isset($column['NULL']) && $column['NULL'] == false) | |
1247 | + $sql .= ' NOT NULL'; | |
1248 | + if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default'])) | |
1249 | + $sql .= ' default NULL'; | |
1250 | + if (isset($column['default'])) | |
1251 | + $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'"); | |
1252 | + if (isset($column['auto_increment'])) | |
1253 | + $sql .= ' auto_increment'; | |
1254 | + $c++; | |
1255 | + } | |
1256 | + } | |
1257 | + | |
1258 | + if (isset($data['primary'])) { | |
1259 | + $sql .= ",\n PRIMARY KEY (`" . $data['primary'] . '`)'; | |
1260 | + } | |
1261 | + | |
1262 | + foreach ($data['keys'] as $key) { | |
1263 | + if (isset($key['name'])) { | |
1264 | + $sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)'; | |
1265 | + } | |
1266 | + } | |
1267 | + $sql .= ') TYPE = ' . $data['type']; | |
1268 | + | |
1269 | + if (isset($data['comment'])) { | |
1270 | + $sql .= " COMMENT = '" . $data['comment'] . "'"; | |
1271 | + } | |
1272 | + if (db_execute($sql)) { | |
1273 | + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')"); | |
1274 | + } | |
1275 | + } else { | |
1276 | + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')"); | |
1277 | + } | |
1278 | +} | |
1279 | + | |
1280 | +function api_plugin_db_changes_remove ($plugin) { | |
1281 | + // Example: api_plugin_db_changes_remove ('thold'); | |
1282 | + | |
1283 | + $tables = db_fetch_assoc("SELECT `table` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='create'", false); | |
1284 | + if (count($tables)) { | |
1285 | + foreach ($tables as $table) { | |
ac01d3f9 | 1286 | + db_execute("DROP TABLE IF EXISTS `" . $table['table'] . "`;"); |
c9a520e2 ER |
1287 | + } |
1288 | + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false); | |
1289 | + } | |
1290 | + $columns = db_fetch_assoc("SELECT `table`, `column` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='addcolumn'", false); | |
1291 | + if (count($columns)) { | |
1292 | + foreach ($columns as $column) { | |
1293 | + db_execute('ALTER TABLE `' . $column['table'] . '` DROP `' . $column['column'] . '`'); | |
1294 | + } | |
1295 | + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false); | |
1296 | + } | |
1297 | +} | |
1298 | + | |
1299 | +function api_plugin_db_add_column ($plugin, $table, $column) { | |
1300 | + // Example: api_plugin_db_add_column ('thold', 'plugin_config', array('name' => 'test' . rand(1, 200), 'type' => 'varchar (255)', 'NULL' => false)); | |
1301 | + | |
1302 | + global $config, $database_default; | |
1303 | + include_once($config['library_path'] . '/database.php'); | |
1304 | + | |
1305 | + $result = db_fetch_assoc('show columns from `' . $table . '`') or die (mysql_error()); | |
1306 | + $columns = array(); | |
1307 | + foreach($result as $index => $arr) { | |
1308 | + foreach ($arr as $t) { | |
1309 | + $columns[] = $t; | |
1310 | + } | |
1311 | + } | |
1312 | + if (isset($column['name']) && !in_array($column['name'], $columns)) { | |
1313 | + $sql = 'ALTER TABLE `' . $table . '` ADD `' . $column['name'] . '`'; | |
1314 | + if (isset($column['type'])) | |
1315 | + $sql .= ' ' . $column['type']; | |
1316 | + if (isset($column['unsigned'])) | |
1317 | + $sql .= ' unsigned'; | |
1318 | + if (isset($column['NULL']) && $column['NULL'] == false) | |
1319 | + $sql .= ' NOT NULL'; | |
1320 | + if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default'])) | |
1321 | + $sql .= ' default NULL'; | |
1322 | + if (isset($column['default'])) | |
1323 | + $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'"); | |
1324 | + if (isset($column['auto_increment'])) | |
1325 | + $sql .= ' auto_increment'; | |
1326 | + if (isset($column['after'])) | |
1327 | + $sql .= ' AFTER ' . $column['after']; | |
1328 | + | |
1329 | + if (db_execute($sql)) { | |
1330 | + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')"); | |
1331 | + } | |
1332 | + } | |
1333 | +} | |
1334 | + | |
1335 | +function api_plugin_install ($plugin) { | |
1336 | + global $config; | |
1337 | + include_once($config['base_path'] . "/plugins/$plugin/setup.php"); | |
1338 | + | |
1339 | + $exists = db_fetch_assoc("SELECT id FROM plugin_config WHERE directory = '$plugin'", false); | |
ac01d3f9 | 1340 | + if (sizeof($exists)) { |
c9a520e2 ER |
1341 | + db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'"); |
1342 | + } | |
1343 | + | |
1344 | + $name = $author = $webpage = $version = ''; | |
1345 | + $function = 'plugin_' . $plugin . '_version'; | |
1346 | + if (function_exists($function)){ | |
1347 | + $info = $function(); | |
1348 | + $name = $info['longname']; | |
1c1c23da SP |
1349 | + if (isset($info['homepage'])) { |
1350 | + $webpage = $info['homepage']; | |
1351 | + }elseif (isset($info['webpage'])) { | |
1352 | + $webpage = $info['webpage']; | |
1353 | + }else{ | |
1354 | + $webpage = "Not Stated"; | |
1355 | + } | |
c9a520e2 ER |
1356 | + $author = $info['author']; |
1357 | + $version = $info['version']; | |
1358 | + } | |
1359 | + | |
1360 | + db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')"); | |
1361 | + | |
1362 | + $function = 'plugin_' . $plugin . '_install'; | |
1363 | + if (function_exists($function)){ | |
1364 | + $function(); | |
1365 | + $ready = api_plugin_check_config ($plugin); | |
1366 | + if ($ready) { | |
1367 | + // Set the plugin as "disabled" so it can go live | |
1368 | + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'"); | |
1369 | + } else { | |
1370 | + // Set the plugin as "needs configuration" | |
1371 | + db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'"); | |
1372 | + } | |
1373 | + } | |
1374 | +} | |
1375 | + | |
1376 | +function api_plugin_uninstall ($plugin) { | |
1377 | + global $config; | |
1378 | + include_once($config['base_path'] . "/plugins/$plugin/setup.php"); | |
1379 | + // Run the Plugin's Uninstall Function first | |
1380 | + $function = 'plugin_' . $plugin . '_uninstall'; | |
1381 | + if (function_exists($function)) { | |
1382 | + $function(); | |
1383 | + } | |
1384 | + api_plugin_remove_hooks ($plugin); | |
1385 | + api_plugin_remove_realms ($plugin); | |
1386 | + db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'"); | |
1387 | + api_plugin_db_changes_remove ($plugin); | |
1388 | +} | |
1389 | + | |
1390 | +function api_plugin_check_config ($plugin) { | |
1391 | + global $config; | |
1392 | + include_once($config['base_path'] . "/plugins/$plugin/setup.php"); | |
1393 | + $function = 'plugin_' . $plugin . '_check_config'; | |
1394 | + if (function_exists($function)) { | |
1395 | + return $function(); | |
1396 | + } | |
1397 | + return TRUE; | |
1398 | +} | |
1399 | + | |
1400 | +function api_plugin_enable ($plugin) { | |
1401 | + $ready = api_plugin_check_config ($plugin); | |
1402 | + if ($ready) { | |
1403 | + api_plugin_enable_hooks ($plugin); | |
1404 | + db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'"); | |
1405 | + } | |
1406 | +} | |
1407 | + | |
1408 | +function api_plugin_is_enabled ($plugin) { | |
1409 | + $status = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = '$plugin'", false); | |
1410 | + if ($status == '1') | |
1411 | + return true; | |
1412 | + return false; | |
1413 | +} | |
1414 | + | |
1415 | +function api_plugin_disable ($plugin) { | |
1416 | + api_plugin_disable_hooks ($plugin); | |
1417 | + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'"); | |
1418 | +} | |
1419 | + | |
1c1c23da SP |
1420 | +function api_plugin_moveup($plugin) { |
1421 | + global $plugins_system; | |
1422 | + | |
1423 | + $sql_where = ""; | |
1424 | + if (sizeof($plugins_system)) { | |
1425 | + foreach($plugins_system as $s) { | |
1426 | + $sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'"; | |
1427 | + } | |
1428 | + | |
1429 | + $sql_where .= ")"; | |
1430 | + } | |
1431 | + | |
1432 | + $id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:"")); | |
1433 | + $temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1; | |
1434 | + $prior_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config WHERE id<$id" . (strlen($sql_where) ? " AND " . $sql_where:"")); | |
1435 | + | |
1436 | + /* update the above plugin to the prior temp id */ | |
1437 | + db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$prior_id"); | |
1438 | + db_execute("UPDATE plugin_config SET id=$prior_id WHERE id=$id"); | |
1439 | + db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id"); | |
1440 | +} | |
1441 | + | |
1442 | +function api_plugin_movedown($plugin) { | |
1443 | + global $plugins_system; | |
1444 | + | |
1445 | + $sql_where = ""; | |
1446 | + if (sizeof($plugins_system)) { | |
1447 | + foreach($plugins_system as $s) { | |
1448 | + $sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'"; | |
1449 | + } | |
1450 | + | |
1451 | + $sql_where .= ")"; | |
1452 | + } | |
1453 | + | |
1454 | + $id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:"")); | |
1455 | + $temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1; | |
1456 | + $next_id = db_fetch_cell("SELECT MIN(id) FROM plugin_config WHERE id>$id" . (strlen($sql_where) ? " AND " . $sql_where:"")); | |
1457 | + | |
1458 | + /* update the above plugin to the prior temp id */ | |
1459 | + db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$next_id"); | |
1460 | + db_execute("UPDATE plugin_config SET id=$next_id WHERE id=$id"); | |
1461 | + db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id"); | |
1462 | +} | |
1463 | + | |
c9a520e2 ER |
1464 | +function api_plugin_register_hook ($plugin, $hook, $function, $file) { |
1465 | + $exists = db_fetch_assoc("SELECT id FROM plugin_hooks WHERE name = '$plugin' AND hook = '$hook'", false); | |
1466 | + if (!count($exists)) { | |
1467 | + $settings = array('config_settings', 'config_arrays', 'config_form'); | |
1468 | + if (!in_array($hook, $settings)) { | |
1469 | + db_execute("INSERT INTO plugin_hooks (name, hook, function, file) VALUES ('$plugin', '$hook', '$function', '$file')"); | |
1470 | + } else { | |
1471 | + db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)"); | |
1472 | + } | |
1473 | + } | |
1474 | +} | |
1475 | + | |
1476 | +function api_plugin_remove_hooks ($plugin) { | |
1477 | + db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'"); | |
1478 | +} | |
1479 | + | |
1480 | +function api_plugin_enable_hooks ($plugin) { | |
1481 | + db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'"); | |
1482 | +} | |
1483 | + | |
1484 | +function api_plugin_disable_hooks ($plugin) { | |
1485 | + db_execute("UPDATE plugin_hooks SET status = 0 WHERE name = '$plugin' AND hook != 'config_settings' AND hook != 'config_arrays' AND hook != 'config_form'"); | |
1486 | +} | |
1487 | + | |
1488 | +function api_plugin_register_realm ($plugin, $file, $display, $admin = false) { | |
1489 | + $exists = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false); | |
1490 | + if (!count($exists)) { | |
1491 | + db_execute("INSERT INTO plugin_realms (plugin, file, display) VALUES ('$plugin', '$file', '$display')"); | |
1492 | + if ($admin) { | |
1493 | + $realm_id = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false); | |
1494 | + $realm_id = $realm_id[0]['id'] + 100; | |
1495 | + $user_id = db_fetch_assoc("SELECT id FROM user_auth WHERE username = 'admin'", false); | |
1496 | + if (count($user_id)) { | |
1497 | + $user_id = $user_id[0]['id']; | |
ac01d3f9 | 1498 | + $exists = db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id = $user_id and realm_id = $realm_id", false); |
c9a520e2 ER |
1499 | + if (!count($exists)) { |
1500 | + db_execute("INSERT INTO user_auth_realm (user_id, realm_id) VALUES ($user_id, $realm_id)"); | |
1501 | + } | |
1502 | + } | |
1503 | + } | |
1504 | + } | |
1505 | +} | |
1506 | + | |
1507 | +function api_plugin_remove_realms ($plugin) { | |
1508 | + $realms = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin'", false); | |
1509 | + foreach ($realms as $realm) { | |
1510 | + $id = $realm['id'] + 100; | |
1511 | + db_execute("DELETE FROM user_auth_realm WHERE realm_id = '$id'"); | |
1512 | + } | |
1513 | + db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'"); | |
1514 | +} | |
1515 | + | |
1516 | +function api_plugin_load_realms () { | |
1517 | + global $user_auth_realms, $user_auth_realm_filenames; | |
1518 | + $plugin_realms = db_fetch_assoc("SELECT * FROM plugin_realms ORDER BY plugin, display", false); | |
1519 | + if (count($plugin_realms)) { | |
1520 | + foreach ($plugin_realms as $plugin_realm) { | |
1521 | + $plugin_files = explode(',', $plugin_realm['file']); | |
1522 | + foreach($plugin_files as $plugin_file) { | |
1523 | + $user_auth_realm_filenames[$plugin_file] = $plugin_realm['id'] + 100; | |
1524 | + } | |
1525 | + $user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display']; | |
1526 | + } | |
1527 | + } | |
1528 | +} | |
1529 | + | |
1530 | +function api_plugin_user_realm_auth ($filename = '') { | |
1531 | + global $user_realms, $user_auth_realms, $user_auth_realm_filenames; | |
1532 | + /* list all realms that this user has access to */ | |
1533 | + if (!isset($user_realms)) { | |
1534 | + if (read_config_option('global_auth') == 'on' || read_config_option('auth_method') != 0) { | |
1535 | + $user_realms = db_fetch_assoc("select realm_id from user_auth_realm where user_id=" . $_SESSION["sess_user_id"], false); | |
1536 | + $user_realms = array_rekey($user_realms, "realm_id", "realm_id"); | |
1537 | + }else{ | |
1538 | + $user_realms = $user_auth_realms; | |
1539 | + } | |
1540 | + } | |
1541 | + if ($filename != '') { | |
1542 | + if (isset($user_realms[$user_auth_realm_filenames{basename($filename)}])) | |
1543 | + return TRUE; | |
1544 | + } | |
1545 | + return FALSE; | |
1546 | +} | |
1547 | + | |
1548 | +function plugin_config_arrays () { | |
1549 | + global $menu; | |
1550 | + $menu['Configuration']['plugins.php'] = 'Plugin Management'; | |
1551 | + api_plugin_load_realms (); | |
1552 | +} | |
1553 | + | |
1554 | +function plugin_draw_navigation_text ($nav) { | |
1555 | + $nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1"); | |
1556 | + return $nav; | |
1557 | +} | |
1558 | + | |
1559 | + | |
1560 | + | |
1561 | + | |
1562 | + | |
1563 | + | |
1564 | + | |
1c1c23da SP |
1565 | diff -Naur cacti-0.8.7g-old/lib/poller.php cacti-0.8.7g/lib/poller.php |
1566 | --- cacti-0.8.7g-old/lib/poller.php 2010-07-09 18:33:46.000000000 -0400 | |
1567 | +++ cacti-0.8.7g/lib/poller.php 2010-07-09 18:34:11.000000000 -0400 | |
1568 | @@ -344,8 +344,11 @@ | |
c9a520e2 ER |
1569 | } |
1570 | } | |
1571 | } | |
1572 | + api_plugin_hook_function('poller_output', $rrd_update_array); | |
1573 | ||
1574 | - $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe); | |
1575 | + if (api_plugin_hook_function('poller_on_demand', $results)) { | |
1576 | + $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe); | |
1577 | + } | |
1578 | } | |
1579 | ||
1580 | return $rrds_processed; | |
1c1c23da SP |
1581 | diff -Naur cacti-0.8.7g-old/lib/rrd.php cacti-0.8.7g/lib/rrd.php |
1582 | --- cacti-0.8.7g-old/lib/rrd.php 2010-07-09 18:33:46.000000000 -0400 | |
1583 | +++ cacti-0.8.7g/lib/rrd.php 2010-07-09 18:34:11.000000000 -0400 | |
ac01d3f9 AZ |
1584 | @@ -419,6 +419,9 @@ |
1585 | ||
1586 | $data_source_path = get_data_source_path($local_data_id, true); | |
1587 | ||
1588 | + /* update the rrdfile if performing a fetch */ | |
1c1c23da | 1589 | + api_plugin_hook_function('rrdtool_function_fetch_cache_check', $local_data_id); |
ac01d3f9 AZ |
1590 | + |
1591 | /* build and run the rrdtool fetch command with all of our data */ | |
1592 | $cmd_line = "fetch $data_source_path AVERAGE -s $start_time -e $end_time"; | |
1593 | if ($resolution > 0) { | |
1594 | @@ -539,6 +542,10 @@ | |
c9a520e2 ER |
1595 | } |
1596 | } | |
1597 | ||
ac01d3f9 | 1598 | + $data = api_plugin_hook_function('rrdtool_function_graph_cache_check', array('local_graph_id' => $local_graph_id,'rra_id' => $rra_id,'rrd_struc' => $rrdtool_pipe,'graph_data_array' => $graph_data_array, 'return' => false)); |
c9a520e2 ER |
1599 | + if (isset($data['return']) && $data['return'] != false) |
1600 | + return $data['return']; | |
1601 | + | |
1602 | /* find the step and how often this graph is updated with new data */ | |
1603 | $ds_step = db_fetch_cell("select | |
1604 | data_template_data.rrd_step | |
ac01d3f9 | 1605 | @@ -1376,6 +1383,13 @@ |
c9a520e2 ER |
1606 | } |
1607 | } | |
1608 | ||
1609 | + $graph_array = api_plugin_hook_function('rrd_graph_graph_options', array('graph_opts' => $graph_opts, 'graph_defs' => $graph_defs, 'txt_graph_items' => $txt_graph_items, 'graph_id' => $local_graph_id, 'start' => $graph_start, 'end' => $graph_end)); | |
1610 | + if (!empty($graph_array)) { | |
1611 | + $graph_defs = $graph_array['graph_defs']; | |
1612 | + $txt_graph_items = $graph_array['txt_graph_items']; | |
1613 | + $graph_opts = $graph_array['graph_opts']; | |
1614 | + } | |
1615 | + | |
1616 | /* either print out the source or pass the source onto rrdtool to get us a nice PNG */ | |
1617 | if (isset($graph_data_array["print_source"])) { | |
1c1c23da | 1618 | print "<PRE>" . htmlspecialchars(read_config_option("path_rrdtool") . " graph " . $graph_opts . $graph_defs . $txt_graph_items) . "</PRE>"; |
ac01d3f9 AZ |
1619 | @@ -1384,13 +1398,19 @@ |
1620 | @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrdtool_pipe); | |
c9a520e2 ER |
1621 | return 0; |
1622 | }else{ | |
1623 | + $graph_data_array = api_plugin_hook_function('prep_graph_array', $graph_data_array); | |
1624 | + | |
1625 | if (isset($graph_data_array["output_flag"])) { | |
1626 | $output_flag = $graph_data_array["output_flag"]; | |
1627 | }else{ | |
1628 | $output_flag = RRDTOOL_OUTPUT_GRAPH_DATA; | |
1629 | } | |
1630 | ||
ac01d3f9 AZ |
1631 | - return @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrdtool_pipe); |
1632 | + $output = @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrdtool_pipe); | |
c9a520e2 ER |
1633 | + |
1634 | + api_plugin_hook_function('rrdtool_function_graph_set_file', array('output' => $output, 'local_graph_id' => $local_graph_id, 'rra_id' => $rra_id)); | |
1635 | + | |
1636 | + return $output; | |
1637 | } | |
1638 | } | |
1639 | } | |
1c1c23da SP |
1640 | diff -Naur cacti-0.8.7g-old/lib/variables.php cacti-0.8.7g/lib/variables.php |
1641 | --- cacti-0.8.7g-old/lib/variables.php 2010-07-09 18:33:46.000000000 -0400 | |
1642 | +++ cacti-0.8.7g/lib/variables.php 2010-07-09 18:34:11.000000000 -0400 | |
c9a520e2 ER |
1643 | @@ -183,6 +183,9 @@ |
1644 | $string = str_replace($l_escape_string . "host_max_oids" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["max_oids"], $string); | |
1645 | $string = str_replace($l_escape_string . "host_id" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["id"], $string); | |
1646 | ||
1647 | + $temp = api_plugin_hook_function('substitute_host_data', array('string' => $string, 'l_escape_string' => $l_escape_string, 'r_escape_string' => $r_escape_string, 'host_id' => $host_id)); | |
1648 | + $string = $temp['string']; | |
1649 | + | |
1650 | return $string; | |
1651 | } | |
1652 | ||
1c1c23da SP |
1653 | diff -Naur cacti-0.8.7g-old/plugins/index.php cacti-0.8.7g/plugins/index.php |
1654 | --- cacti-0.8.7g-old/plugins/index.php 1969-12-31 19:00:00.000000000 -0500 | |
1655 | +++ cacti-0.8.7g/plugins/index.php 2010-07-09 18:34:11.000000000 -0400 | |
c9a520e2 ER |
1656 | @@ -0,0 +1,5 @@ |
1657 | +<?php | |
1658 | + | |
1659 | +header("Location:../index.php"); | |
1660 | + | |
1661 | +?> | |
1c1c23da SP |
1662 | diff -Naur cacti-0.8.7g-old/plugins.php cacti-0.8.7g/plugins.php |
1663 | --- cacti-0.8.7g-old/plugins.php 1969-12-31 19:00:00.000000000 -0500 | |
1664 | +++ cacti-0.8.7g/plugins.php 2010-07-09 18:34:11.000000000 -0400 | |
1665 | @@ -0,0 +1,647 @@ | |
c9a520e2 | 1666 | +<?php |
ac01d3f9 AZ |
1667 | +/* |
1668 | + +-------------------------------------------------------------------------+ | |
1669 | + | Copyright (C) 2004-2010 The Cacti Group | | |
1670 | + | | | |
1671 | + | This program is free software; you can redistribute it and/or | | |
1672 | + | modify it under the terms of the GNU General Public License | | |
1673 | + | as published by the Free Software Foundation; either version 2 | | |
1674 | + | of the License, or (at your option) any later version. | | |
1675 | + | | | |
1676 | + | This program is distributed in the hope that it will be useful, | | |
1677 | + | but WITHOUT ANY WARRANTY; without even the implied warranty of | | |
1678 | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | |
1679 | + | GNU General Public License for more details. | | |
1680 | + +-------------------------------------------------------------------------+ | |
1681 | + | Cacti: The Complete RRDTool-based Graphing Solution | | |
1682 | + +-------------------------------------------------------------------------+ | |
1683 | + | This code is designed, written, and maintained by the Cacti Group. See | | |
1684 | + | about.php and/or the AUTHORS file for specific developer information. | | |
1685 | + +-------------------------------------------------------------------------+ | |
1686 | + | http://www.cacti.net/ | | |
1687 | + +-------------------------------------------------------------------------+ | |
1688 | +*/ | |
c9a520e2 ER |
1689 | + |
1690 | +include("./include/auth.php"); | |
1691 | + | |
1c1c23da | 1692 | +define("MAX_DISPLAY_PAGES", 21); |
c9a520e2 | 1693 | + |
1c1c23da SP |
1694 | +$actions = array("install" => "Install", |
1695 | + "enable" => "Enable", | |
1696 | + "disable" => "Disable", | |
1697 | + "uninstall" => "Uninstall", | |
1698 | +// "check" => "Check" | |
c9a520e2 ER |
1699 | +); |
1700 | + | |
1c1c23da SP |
1701 | +$status_names = array( |
1702 | + -2 => 'Disabled', | |
1703 | + -1 => 'Active', | |
1704 | + 0 => 'Not Installed', | |
1705 | + 1 => 'Active', | |
1706 | + 2 => 'Awaiting Configuration', | |
1707 | + 3 => 'Awaiting Upgrade', | |
1708 | + 4 => 'Installed' | |
1709 | +); | |
c9a520e2 | 1710 | + |
1c1c23da SP |
1711 | +/* get the comprehensive list of plugins */ |
1712 | +$pluginslist = retrieve_plugin_list(); | |
c9a520e2 | 1713 | + |
1c1c23da SP |
1714 | +/* Check to see if we are installing, etc... */ |
1715 | +$modes = array('installold', 'uninstallold', 'install', 'uninstall', 'disable', 'enable', 'check', 'moveup', 'movedown'); | |
c9a520e2 ER |
1716 | + |
1717 | +if (isset($_GET['mode']) && in_array($_GET['mode'], $modes) && isset($_GET['id'])) { | |
c9a520e2 ER |
1718 | + input_validate_input_regex(get_request_var("id"), "^([a-zA-Z0-9]+)$"); |
1719 | + | |
1720 | + $mode = $_GET['mode']; | |
1c1c23da | 1721 | + $id = sanitize_search_string($_GET['id']); |
c9a520e2 ER |
1722 | + |
1723 | + switch ($mode) { | |
1c1c23da SP |
1724 | + case 'installold': |
1725 | + api_plugin_install_old($id); | |
1726 | + header("Location: plugins.php"); | |
1727 | + exit; | |
1728 | + break; | |
1729 | + case 'uninstallold': | |
1730 | + api_plugin_uninstall_old($id); | |
1731 | + header("Location: plugins.php"); | |
1732 | + exit; | |
1733 | + break; | |
c9a520e2 ER |
1734 | + case 'install': |
1735 | + api_plugin_install($id); | |
1c1c23da SP |
1736 | + header("Location: plugins.php"); |
1737 | + exit; | |
c9a520e2 ER |
1738 | + break; |
1739 | + case 'uninstall': | |
1c1c23da | 1740 | + if (!in_array($id, $pluginslist)) break; |
c9a520e2 | 1741 | + api_plugin_uninstall($id); |
1c1c23da SP |
1742 | + header("Location: plugins.php"); |
1743 | + exit; | |
c9a520e2 ER |
1744 | + break; |
1745 | + case 'disable': | |
1c1c23da SP |
1746 | + if (!in_array($id, $pluginslist)) break; |
1747 | + api_plugin_disable($id); | |
1748 | + header("Location: plugins.php"); | |
1749 | + exit; | |
c9a520e2 ER |
1750 | + break; |
1751 | + case 'enable': | |
1c1c23da SP |
1752 | + if (!in_array($id, $pluginslist)) break; |
1753 | + api_plugin_enable($id); | |
1754 | + header("Location: plugins.php"); | |
1755 | + exit; | |
c9a520e2 ER |
1756 | + break; |
1757 | + case 'check': | |
1c1c23da SP |
1758 | + if (!in_array($id, $pluginslist)) break; |
1759 | + break; | |
1760 | + case 'moveup': | |
1761 | + if (!in_array($id, $pluginslist)) break; | |
1762 | + if (is_system_plugin($id)) break; | |
1763 | + api_plugin_moveup($id); | |
1764 | + header("Location: plugins.php"); | |
1765 | + exit; | |
1766 | + break; | |
1767 | + case 'movedown': | |
1768 | + if (!in_array($id, $pluginslist)) break; | |
1769 | + if (is_system_plugin($id)) break; | |
1770 | + api_plugin_movedown($id); | |
1771 | + header("Location: plugins.php"); | |
1772 | + exit; | |
c9a520e2 ER |
1773 | + break; |
1774 | + } | |
1775 | +} | |
1776 | + | |
1777 | +function retrieve_plugin_list () { | |
1778 | + $pluginslist = array(); | |
1779 | + $temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name'); | |
1780 | + foreach ($temp as $t) { | |
1781 | + $pluginslist[] = $t['directory']; | |
1782 | + } | |
1783 | + return $pluginslist; | |
1784 | +} | |
1785 | + | |
1c1c23da | 1786 | +include("./include/top_header.php"); |
c9a520e2 | 1787 | + |
1c1c23da | 1788 | +update_show_current(); |
c9a520e2 | 1789 | + |
1c1c23da | 1790 | +include("./include/bottom_footer.php"); |
c9a520e2 | 1791 | + |
c9a520e2 | 1792 | + |
1c1c23da SP |
1793 | +function api_plugin_install_old ($plugin) { |
1794 | + global $config; | |
1795 | + if (!file_exists($config['base_path'] . "/plugins/$plugin/setup.php")) { | |
1796 | + return false; | |
c9a520e2 | 1797 | + } |
1c1c23da SP |
1798 | + $oldplugins = read_config_option('oldplugins'); |
1799 | + $oldplugins = explode(',', $oldplugins); | |
1800 | + if (!in_array($plugin, $oldplugins)) { | |
1801 | + include_once($config['base_path'] . "/plugins/$plugin/setup.php"); | |
1802 | + $function = 'plugin_init_' . $plugin; | |
1803 | + if (function_exists($function)){ | |
1804 | + $oldplugins[] = $plugin; | |
1805 | + $oldplugins = implode(',', $oldplugins); | |
1806 | + set_config_option('oldplugins', $oldplugins); | |
1807 | + unset($_SESSION['sess_config_array']['oldplugins']); | |
1808 | + return true; | |
1809 | + } else { | |
1810 | + return false; | |
1811 | + } | |
1812 | + } | |
1813 | + return false; | |
1814 | +} | |
c9a520e2 | 1815 | + |
1c1c23da SP |
1816 | +function api_plugin_uninstall_old ($plugin) { |
1817 | + global $config; | |
1818 | + $oldplugins = read_config_option('oldplugins'); | |
1819 | + $oldplugins = explode(',', $oldplugins); | |
1820 | + if (!empty($oldplugins)) { | |
1821 | + if (in_array($plugin, $oldplugins)) { | |
1822 | + for ($a = 0; $a < count($oldplugins); $a++) { | |
1823 | + if ($oldplugins[$a] == $plugin) { | |
1824 | + unset($oldplugins[$a]); | |
1825 | + break; | |
1826 | + } | |
1827 | + } | |
1828 | + $oldplugins = implode(',', $oldplugins); | |
1829 | + set_config_option('oldplugins', $oldplugins); | |
1830 | + unset($_SESSION['sess_config_array']['oldplugins']); | |
1831 | + return true; | |
1832 | + } | |
1833 | + } | |
1834 | + return false; | |
1835 | +} | |
c9a520e2 ER |
1836 | + |
1837 | +function update_show_updates () { | |
1838 | + global $pluginslist, $colors, $config, $plugin_architecture; | |
1839 | + | |
1840 | + $cinfo = array(); | |
1841 | + sort($pluginslist); | |
1842 | + | |
1843 | + $cinfo = update_get_plugin_info (); | |
1844 | + | |
1845 | + $x = 0; | |
1846 | + | |
1847 | + $info = update_get_cached_plugin_info(); | |
1848 | + | |
1849 | + $cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ; | |
1c1c23da | 1850 | + if (isset($cinfo['cacti_plugin_arch']['version'])) { |
c9a520e2 | 1851 | + $archnew = update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']); |
1c1c23da | 1852 | + } else { |
c9a520e2 | 1853 | + $archnew = 0; |
1c1c23da | 1854 | + } |
c9a520e2 ER |
1855 | + |
1856 | + if ($cactinew) { | |
1857 | + $x++; | |
1858 | + print "<tr><td width='25%' valign=top><table width='100%'>"; | |
1859 | + html_header(array("Cacti"), 2); | |
1860 | + form_alternate_row_color($colors["alternate"],$colors["light"], 0); | |
1861 | + print "<td width='25%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr>"; | |
1862 | + form_alternate_row_color($colors["alternate"],$colors["light"], 0); | |
1863 | + print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti']['changes']) . "</td></tr></table>"; | |
1864 | + } | |
1865 | + if (isset($plugin_architecture['version']) && $archnew) { | |
1866 | + $x++; | |
1867 | + print "<table width='100%'>"; | |
1868 | + html_header(array("Plugin Architecture"), 2); | |
1869 | + form_alternate_row_color($colors["alternate"],$colors["light"], 0); | |
1870 | + print "<td width='25%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td>"; | |
1871 | + form_alternate_row_color($colors["alternate"],$colors["light"], 0); | |
1872 | + print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti_plugin_arch']['changes']) . "</td></tr></table>"; | |
1873 | + } | |
1874 | + print "<table width='100%' cellspacing=0 cellpadding=3>"; | |
1875 | + | |
1876 | + foreach ($pluginslist as $plugin) { | |
1877 | + if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) { | |
1878 | + $x++; | |
1879 | + print "<table width='100%'>"; | |
1880 | + html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2); | |
1881 | + form_alternate_row_color($colors["alternate"],$colors["light"], 0); | |
1882 | + print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>"; | |
1883 | + form_alternate_row_color($colors["alternate"],$colors["light"], 0); | |
1884 | + print "<td><strong>Version:</strong></td><td>" . $info[$plugin]['version'] . "</td>"; | |
1885 | + form_alternate_row_color($colors["alternate"],$colors["light"], 0); | |
1886 | + print "<td><strong>Author:</strong></td><td>" . (isset($cinfo[$plugin]['author']) && $cinfo[$plugin]['author'] != '' ? (isset($cinfo[$plugin]['email']) && $cinfo[$plugin]['email'] != '' ? "<a href='mailto:" . $cinfo[$plugin]['email'] . "'>" . $cinfo[$plugin]['author'] . "</a>" : $cinfo[$plugin]['author']) : "") . "</td>"; | |
1887 | + form_alternate_row_color($colors["alternate"],$colors["light"], 0); | |
1888 | + print "<td><strong>Home Page:</strong></td><td>" . (isset($cinfo[$plugin]['webpage']) && $cinfo[$plugin]['webpage'] != '' ? "<a href='" . $cinfo[$plugin]['webpage'] . "'>" . $cinfo[$plugin]['webpage'] . "</a>" : "") . "</td>"; | |
1889 | + form_alternate_row_color($colors["alternate"],$colors["light"], 0); | |
1890 | + print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info[$plugin]['changes']) . "</td>"; | |
1891 | + | |
1892 | + print "</tr></table>"; | |
1893 | + } | |
1894 | + } | |
1895 | + if ($x == 0) | |
1896 | + print "<br><center><b>There are currently no Updates!</b></center><br>"; | |
1897 | + print "</table>"; | |
1898 | + html_end_box(TRUE); | |
1899 | +} | |
1900 | + | |
1901 | +function update_check_if_newer() { | |
1902 | + return false; | |
1903 | +} | |
1904 | + | |
1c1c23da SP |
1905 | +function plugins_temp_table_exists($table) { |
1906 | + return sizeof(db_fetch_row("SHOW TABLES LIKE '$table'")); | |
1907 | +} | |
c9a520e2 | 1908 | + |
1c1c23da SP |
1909 | +function plugins_load_temp_table() { |
1910 | + global $config, $plugins; | |
c9a520e2 | 1911 | + |
1c1c23da | 1912 | + $pluginslist = retrieve_plugin_list(); |
c9a520e2 | 1913 | + |
1c1c23da SP |
1914 | + if (isset($_SESSION["plugin_temp_table"])) { |
1915 | + $table = $_SESSION["plugin_temp_table"]; | |
1916 | + }else{ | |
1917 | + $table = "plugin_temp_table_" . rand(); | |
1918 | + } | |
c9a520e2 | 1919 | + |
1c1c23da SP |
1920 | + while (true) { |
1921 | + if (!plugins_temp_table_exists($table)) { | |
1922 | + $_SESSION["plugin_temp_table"] = $table; | |
1923 | + db_execute("CREATE TEMPORARY TABLE $table LIKE plugin_config"); | |
1924 | + db_execute("INSERT INTO $table SELECT * FROM plugin_config"); | |
1925 | + break; | |
1926 | + }else{ | |
1927 | + $table = "plugin_temp_table_" . rand(); | |
1928 | + } | |
1929 | + } | |
c9a520e2 ER |
1930 | + |
1931 | + $path = $config['base_path'] . '/plugins/'; | |
1932 | + $dh = opendir($path); | |
1933 | + while (($file = readdir($dh)) !== false) { | |
1c1c23da SP |
1934 | + if ((is_dir("$path/$file")) && (file_exists("$path/$file/setup.php")) && (!in_array($file, $pluginslist))) { |
1935 | + if (!function_exists('plugin_' . $file . '_install')) { | |
c9a520e2 ER |
1936 | + include_once("$path/$file/setup.php"); |
1937 | + if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) { | |
1938 | + $function = $file . '_version'; | |
1939 | + $cinfo[$file] = $function(); | |
1c1c23da SP |
1940 | + if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown'; |
1941 | + if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated'; | |
1942 | + if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage']; | |
1943 | + if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['longname'] = ucfirst($file); | |
c9a520e2 ER |
1944 | + $cinfo[$file]['status'] = -2; |
1945 | + if (in_array($file, $plugins)) { | |
1946 | + $cinfo[$file]['status'] = -1; | |
1947 | + } | |
1c1c23da SP |
1948 | + db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version) |
1949 | + VALUES ('" . | |
1950 | + $file . "', '" . | |
1951 | + $cinfo[$file]['longname'] . "', '" . | |
1952 | + $cinfo[$file]['status'] . "', '" . | |
1953 | + $cinfo[$file]['author'] . "', '" . | |
1954 | + $cinfo[$file]['homepage'] . "', '" . | |
1955 | + $cinfo[$file]['version'] . "')"); | |
c9a520e2 ER |
1956 | + $pluginslist[] = $file; |
1957 | + } else if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) { | |
1958 | + $function = $file . '_version'; | |
1959 | + $cinfo[$file] = $function(); | |
1960 | + $cinfo[$file]['status'] = 0; | |
1c1c23da SP |
1961 | + if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown'; |
1962 | + if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated'; | |
1963 | + if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage']; | |
1964 | + if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['homepage'] = ucfirst($file); | |
1965 | + db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version) | |
1966 | + VALUES ('" . | |
1967 | + $file . "', '" . | |
1968 | + $cinfo[$file]['longname'] . "', '" . | |
1969 | + $cinfo[$file]['status'] . "', '" . | |
1970 | + $cinfo[$file]['author'] . "', '" . | |
1971 | + $cinfo[$file]['homepage'] . "', '" . | |
1972 | + $cinfo[$file]['version'] . "')"); | |
c9a520e2 ER |
1973 | + $pluginslist[] = $file; |
1974 | + } | |
1c1c23da SP |
1975 | + }else{ |
1976 | + cacti_log("WARNING: Install function already exists for plugin directory '$file'", false); | |
c9a520e2 ER |
1977 | + } |
1978 | + } | |
1979 | + } | |
1980 | + closedir($dh); | |
1981 | + | |
1c1c23da SP |
1982 | + return $table; |
1983 | +} | |
1984 | + | |
1985 | +function update_show_current () { | |
1986 | + global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names, $actions; | |
1987 | + | |
1988 | + /* ================= input validation ================= */ | |
1989 | + input_validate_input_number(get_request_var_request("page")); | |
1990 | + /* ==================================================== */ | |
1991 | + | |
1992 | + /* clean up search string */ | |
1993 | + if (isset($_REQUEST["filter"])) { | |
1994 | + $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); | |
c9a520e2 | 1995 | + } |
c9a520e2 | 1996 | + |
1c1c23da SP |
1997 | + /* clean up sort_column */ |
1998 | + if (isset($_REQUEST["sort_column"])) { | |
1999 | + $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); | |
2000 | + } | |
c9a520e2 | 2001 | + |
1c1c23da SP |
2002 | + /* clean up search string */ |
2003 | + if (isset($_REQUEST["sort_direction"])) { | |
2004 | + $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); | |
2005 | + } | |
c9a520e2 | 2006 | + |
1c1c23da SP |
2007 | + /* if the user pushed the 'clear' button */ |
2008 | + if (isset($_REQUEST["clear_x"])) { | |
2009 | + kill_session_var("sess_plugins_filter"); | |
2010 | + kill_session_var("sess_plugins_sort_column"); | |
2011 | + kill_session_var("sess_plugins_sort_direction"); | |
2012 | + | |
2013 | + unset($_REQUEST["page"]); | |
2014 | + unset($_REQUEST["filter"]); | |
2015 | + unset($_REQUEST["sort_column"]); | |
2016 | + unset($_REQUEST["sort_direction"]); | |
2017 | + $_REQUEST["page"] = 1; | |
2018 | + } | |
c9a520e2 | 2019 | + |
1c1c23da SP |
2020 | + /* remember these search fields in session vars so we don't have to keep passing them around */ |
2021 | + load_current_session_value("filter", "sess_plugins_filter", ""); | |
2022 | + load_current_session_value("sort_column", "sess_plugins_sort_column", "name"); | |
2023 | + load_current_session_value("sort_direction", "sess_plugins_sort_direction", "ASC"); | |
2024 | + load_current_session_value("page", "sess_plugins_current_page", "1"); | |
2025 | + | |
2026 | + $table = plugins_load_temp_table(); | |
2027 | + | |
2028 | + html_start_box("<strong>Plugin Management</strong> (Cacti Version: " . $config["cacti_version"] . | |
2029 | + (isset($plugin_architecture['version']) ? ", Plugin Architecture Version: " . $plugin_architecture['version']:"") . | |
2030 | + ")", "100%", $colors["header"], "3", "center", ""); | |
2031 | + | |
2032 | + ?> | |
2033 | + <tr bgcolor="#<?php print $colors['panel'];?>"> | |
2034 | + <td class="noprint"> | |
2035 | + <form name="form_plugins" method="get" action="plugins.php"> | |
2036 | + <table width="100%" cellpadding="0" cellspacing="0"> | |
2037 | + <tr class="noprint"> | |
2038 | + <td nowrap style='white-space: nowrap;' width="50"> | |
2039 | + Search: | |
2040 | + </td> | |
2041 | + <td width="1"> | |
2042 | + <input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>"> | |
2043 | + </td> | |
2044 | + <td nowrap style='white-space: nowrap;'> | |
2045 | + <input type="submit" value="Go" title="Set/Refresh Filters"> | |
2046 | + <input type="submit" name="clear_x" value="Clear" title="Clear Filters"> | |
2047 | + </td> | |
2048 | + </tr> | |
2049 | + </table> | |
2050 | + <input type='hidden' name='page' value='1'> | |
2051 | + </form> | |
2052 | + </td> | |
2053 | + </tr> | |
2054 | + <?php | |
2055 | + | |
2056 | + html_end_box(); | |
2057 | + | |
2058 | + /* print checkbox form for validation */ | |
2059 | + print "<form name='chk' method='post' action='plugins.php'>\n"; | |
2060 | + | |
2061 | + html_start_box("", "100%", $colors["header"], "3", "center", ""); | |
2062 | + | |
2063 | + /* form the 'where' clause for our main sql query */ | |
2064 | + $sql_where = "WHERE ($table.name LIKE '%%" . get_request_var_request("filter") . "%%')"; | |
c9a520e2 | 2065 | + |
1c1c23da SP |
2066 | + if (get_request_var_request("sort_column") == "version") { |
2067 | + $sortc = "version+0"; | |
2068 | + }else{ | |
2069 | + $sortc = get_request_var_request("sort_column"); | |
2070 | + } | |
2071 | + | |
2072 | + if (get_request_var_request("sort_column") == "id") { | |
2073 | + $sortd = "ASC"; | |
2074 | + }else{ | |
2075 | + $sortd = get_request_var_request("sort_direction"); | |
2076 | + } | |
2077 | + | |
2078 | + $total_rows = db_fetch_cell("SELECT | |
2079 | + count(*) | |
2080 | + FROM $table | |
2081 | + $sql_where"); | |
2082 | + | |
2083 | + $plugins = db_fetch_assoc("SELECT * | |
2084 | + FROM $table | |
2085 | + $sql_where | |
2086 | + ORDER BY " . $sortc . " " . $sortd . " | |
2087 | + LIMIT " . (read_config_option("num_rows_device")*(get_request_var_request("page")-1)) . "," . read_config_option("num_rows_device")); | |
2088 | + | |
2089 | + db_execute("DROP TABLE $table"); | |
2090 | + | |
2091 | + /* generate page list */ | |
2092 | + $url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "plugins.php?filter=" . get_request_var_request("filter")); | |
2093 | + | |
2094 | + if ($total_rows == 0) { | |
2095 | + $nav = "<tr bgcolor='#" . $colors["header"] . "'> | |
2096 | + <td colspan='9'> | |
2097 | + <table width='100%' cellspacing='0' cellpadding='0' border='0'> | |
2098 | + <tr> | |
2099 | + <td align='center' class='textHeaderDark'> | |
2100 | + No Plugins Found | |
2101 | + </td>\n | |
2102 | + </tr> | |
2103 | + </table> | |
2104 | + </td> | |
2105 | + </tr>\n"; | |
2106 | + }elseif ($total_rows < read_config_option("num_rows_device")) { | |
2107 | + $nav = "<tr bgcolor='#" . $colors["header"] . "'> | |
2108 | + <td colspan='9'> | |
2109 | + <table width='100%' cellspacing='0' cellpadding='0' border='0'> | |
2110 | + <tr> | |
2111 | + <td align='center' class='textHeaderDark'> | |
2112 | + Showing All $total_rows Rows | |
2113 | + </td>\n | |
2114 | + </tr> | |
2115 | + </table> | |
2116 | + </td> | |
2117 | + </tr>\n"; | |
2118 | + }else{ | |
2119 | + $nav = "<tr bgcolor='#" . $colors["header"] . "'> | |
2120 | + <td colspan='9'> | |
2121 | + <table width='100%' cellspacing='0' cellpadding='0' border='0'> | |
2122 | + <tr> | |
2123 | + <td align='left' class='textHeaderDark'> | |
2124 | + <strong><< "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("plugins.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page")-1)) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong> | |
2125 | + </td>\n | |
2126 | + <td align='center' class='textHeaderDark'> | |
2127 | + Showing Rows " . ((read_config_option("num_rows_device")*(get_request_var_request("page")-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_device")) || ($total_rows < (read_config_option("num_rows_device")*get_request_var_request("page")))) ? $total_rows : (read_config_option("num_rows_device")*get_request_var_request("page"))) . " of $total_rows [$url_page_select] | |
2128 | + </td>\n | |
2129 | + <td align='right' class='textHeaderDark'> | |
2130 | + <strong>"; if ((get_request_var_request("page") * read_config_option("num_rows_device")) < $total_rows) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("plugins.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page")+1)) . "'>"; } $nav .= "Next"; if ((get_request_var_request("page") * read_config_option("num_rows_device")) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong> | |
2131 | + </td>\n | |
2132 | + </tr> | |
2133 | + </table> | |
2134 | + </td> | |
2135 | + </tr>\n"; | |
2136 | + } | |
2137 | + | |
2138 | + print $nav; | |
2139 | + | |
2140 | + $display_text = array( | |
2141 | + "nosort" => array("Actions", ""), | |
2142 | + "directory" => array("Name", "ASC"), | |
2143 | + "id" => array("Load Order", "ASC"), | |
2144 | + "name" => array("Description", "ASC"), | |
2145 | + "nosort1" => array("Type", "ASC"), | |
2146 | + "status" => array("Status", "ASC"), | |
2147 | + "author" => array("Author", "ASC"), | |
2148 | + "webpage" => array("Web Page", "ASC"), | |
2149 | + "version" => array("Version", "ASC")); | |
2150 | + | |
2151 | + html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), 1); | |
2152 | + | |
2153 | + $i = 0; | |
2154 | + if (sizeof($plugins)) { | |
2155 | + if (get_request_var_request("sort_column") == "id") { | |
2156 | + $inst_system_plugins = get_system_plugins($plugins); | |
2157 | + if (sizeof($inst_system_plugins)) { | |
2158 | + foreach($inst_system_plugins as $plugin) { | |
2159 | + form_alternate_row_color($colors["alternate"], $colors["light"], $i); $i++; | |
2160 | + print format_plugin_row($plugin, false, false, true); | |
c9a520e2 | 2161 | + } |
c9a520e2 | 2162 | + } |
1c1c23da | 2163 | + } |
c9a520e2 | 2164 | + |
1c1c23da SP |
2165 | + $j = 0; |
2166 | + foreach ($plugins as $plugin) { | |
2167 | + if ((isset($plugins[$j+1]) && $plugins[$j+1]['status'] < 0) || (!isset($plugins[$j+1]))) { | |
2168 | + $last_plugin = true; | |
2169 | + }else{ | |
2170 | + $last_plugin = false; | |
c9a520e2 | 2171 | + } |
1c1c23da SP |
2172 | + if ($plugin['status'] <= 0 || is_system_plugin($plugin) || (get_request_var_request('sort_column') != 'id')) { |
2173 | + $load_ordering = false; | |
2174 | + }else{ | |
2175 | + $load_ordering = true; | |
2176 | + } | |
2177 | + | |
2178 | + if (get_request_var_request("sort_column") == "id") { | |
2179 | + if (!is_system_plugin($plugin)) { | |
2180 | + form_alternate_row_color($colors["alternate"], $colors["light"], $i); | |
2181 | + print format_plugin_row($plugin, $last_plugin, $load_ordering, false); | |
2182 | + $i++; | |
2183 | + } | |
2184 | + }else{ | |
2185 | + form_alternate_row_color($colors["alternate"], $colors["light"], $i); | |
2186 | + print format_plugin_row($plugin, $last_plugin, $load_ordering, is_system_plugin($plugin)); | |
2187 | + $i++; | |
2188 | + } | |
2189 | + | |
2190 | + $j++; | |
c9a520e2 | 2191 | + } |
c9a520e2 | 2192 | + |
1c1c23da SP |
2193 | + print $nav; |
2194 | + }else{ | |
2195 | + print "<tr><td><em>No Plugins Found</em></td></tr>"; | |
2196 | + } | |
c9a520e2 | 2197 | + |
1c1c23da | 2198 | + html_end_box(false); |
c9a520e2 | 2199 | + |
1c1c23da SP |
2200 | + html_start_box("", "100%", $colors["header"], "3", "center", ""); |
2201 | + echo "<tr><td colspan=10><strong>NOTE:</strong> Please sort by 'Load Order' to change plugin load ordering.<br><strong>NOTE:</strong> SYSTEM plugins can not be ordered.</td></tr>"; | |
2202 | + html_end_box(); | |
c9a520e2 | 2203 | + |
1c1c23da SP |
2204 | + print "</form>\n"; |
2205 | +} | |
c9a520e2 | 2206 | + |
1c1c23da SP |
2207 | +function format_plugin_row($plugin, $last_plugin, $include_ordering, $system_plugin) { |
2208 | + global $status_names; | |
2209 | + static $first_plugin = true; | |
c9a520e2 | 2210 | + |
1c1c23da SP |
2211 | + $row = plugin_actions($plugin); |
2212 | + $row .= "<td><strong>" . (strlen(get_request_var_request("filter")) ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", ucfirst($plugin["directory"])) : ucfirst($plugin["directory"])) . "</strong></td>"; | |
2213 | + if ($include_ordering) { | |
2214 | + $row .= "<td style='white-space:nowrap;'>"; | |
2215 | + if (!$first_plugin) { | |
2216 | + $row .= "<a href='" . htmlspecialchars("plugins.php?mode=moveup&id=" . $plugin['directory']) . "' title='Order Before Prevous Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/move_up.gif'></a>"; | |
2217 | + }else{ | |
2218 | + $row .= "<a href='#' title='Can NOT Reduce Load Order' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'></a>"; | |
2219 | + } | |
2220 | + if (!$last_plugin) { | |
2221 | + $row .= "<a href='" . htmlspecialchars("plugins.php?mode=movedown&id=" . $plugin['directory']) . "' title='Order After Next Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/move_down.gif'></a>"; | |
2222 | + }else{ | |
2223 | + $row .= "<a href='#' title='Can Increase Load Order' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'></a>"; | |
c9a520e2 | 2224 | + } |
1c1c23da SP |
2225 | + $row .= "</td>\n"; |
2226 | + }else{ | |
2227 | + $row .= "<td></td>\n"; | |
c9a520e2 | 2228 | + } |
c9a520e2 | 2229 | + |
1c1c23da SP |
2230 | + $row .= "<td style='white-space:nowrap;'>" . (strlen(get_request_var_request("filter")) ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $plugin["name"]) : $plugin["name"]) . "</td>\n"; |
2231 | + $row .= "<td style='white-space:nowrap;'>" . ($system_plugin ? "System": ($plugin['status'] < 0 ? "Old PIA":"General")) . "</td>\n"; | |
2232 | + $row .= "<td style='white-space:nowrap;'>" . $status_names[$plugin["status"]] . "</td>\n"; | |
2233 | + $row .= "<td style='white-space:nowrap;'>" . $plugin["author"] . "</td>\n"; | |
2234 | + $row .= "<td><a href='" . htmlspecialchars($plugin["webpage"]) . "'>" . htmlspecialchars($plugin["webpage"]) . "</a></td>\n"; | |
2235 | + $row .= "<td>" . $plugin["version"] . "</td>\n"; | |
2236 | + $row .= "</tr>\n"; | |
c9a520e2 | 2237 | + |
1c1c23da SP |
2238 | + if ($include_ordering) { |
2239 | + $first_plugin = false; | |
2240 | + } | |
c9a520e2 | 2241 | + |
1c1c23da SP |
2242 | + return $row; |
2243 | +} | |
c9a520e2 | 2244 | + |
1c1c23da SP |
2245 | +function plugin_actions($plugin) { |
2246 | + $link = "<td>"; | |
2247 | + switch ($plugin['status']) { | |
2248 | + case "-2": // Old PA Not Installed | |
2249 | + $link .= "<a href='" . htmlspecialchars("plugins.php?mode=installold&id=" . $plugin['directory']) . "' title='Install Old Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/install_icon.png'></a>"; | |
2250 | + $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>"; | |
2251 | + break; | |
2252 | + case "-1": // Old PA Currently Active | |
2253 | + $oldplugins = read_config_option('oldplugins'); | |
2254 | + $oldplugins = explode(',', $oldplugins); | |
2255 | + if (in_array($plugin['directory'], $oldplugins)) { | |
2256 | + $link .= "<a href='" . htmlspecialchars("plugins.php?mode=uninstallold&id=" . $plugin['directory']) . "' title='Uninstall Old Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/uninstall_icon.gif'></a>"; | |
2257 | + } else { | |
2258 | + $link .= "<a href='#' title='Please Uninstall from config.php' class='linkEditMain'><img style='padding:1px;' align='absmiddle' border='0' src='images/install_icon_disabled.png'></a>"; | |
c9a520e2 | 2259 | + } |
1c1c23da SP |
2260 | + $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>"; |
2261 | + break; | |
2262 | + case "0": // Not Installed | |
2263 | + $link .= "<a href='" . htmlspecialchars("plugins.php?mode=install&id=" . $plugin['directory']) . "' title='Install Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/install_icon.png'></a>"; | |
2264 | + $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>"; | |
2265 | + break; | |
2266 | + case "1": // Currently Active | |
2267 | + $link .= "<a href='" . htmlspecialchars("plugins.php?mode=uninstall&id=" . $plugin['directory']) . "' title='Uninstall Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/uninstall_icon.gif'></a>"; | |
2268 | + $link .= "<a href='" . htmlspecialchars("plugins.php?mode=disable&id=" . $plugin['directory']) . "' title='Disable Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/disable_icon.png'></a>"; | |
2269 | + break; | |
2270 | + case "4": // Installed but not active | |
2271 | + $link .= "<a href='" . htmlspecialchars("plugins.php?mode=uninstall&id=" . $plugin['directory']) . "' title='Uninstall Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/uninstall_icon.gif'></a>"; | |
2272 | + $link .= "<a href='" . htmlspecialchars("plugins.php?mode=enable&id=" . $plugin['directory']) . "' title='Enable Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/enable_icon.png'></a>"; | |
2273 | + break; | |
2274 | + default: // Old PIA | |
2275 | + $link .= "<a href='#' title='Please Install/Uninstall from config.php' class='linkEditMain'><img style='padding:1px;' align='absmiddle' border='0' src='images/install_icon_disabled.png'></a>"; | |
2276 | + $link .= "<a href='#' title='Enabling from the UI is not supported' class='linkEditMain'><img style='padding:1px;' align='absmiddle' border='0' src='images/enable_icon_disabled.png'></a>"; | |
2277 | + break; | |
2278 | + } | |
2279 | + $link .= "</td>"; | |
c9a520e2 | 2280 | + |
1c1c23da SP |
2281 | + return $link; |
2282 | +} | |
c9a520e2 | 2283 | + |
1c1c23da SP |
2284 | +function is_system_plugin($plugin) { |
2285 | + global $plugins_system; | |
2286 | + | |
2287 | + if (is_array($plugin)) { | |
2288 | + $plugin = $plugin["directory"]; | |
c9a520e2 | 2289 | + } |
1c1c23da SP |
2290 | + |
2291 | + if (!in_array($plugin, $plugins_system)) { | |
2292 | + return false; | |
2293 | + }else{ | |
2294 | + return true; | |
c9a520e2 | 2295 | + } |
c9a520e2 ER |
2296 | +} |
2297 | + | |
1c1c23da SP |
2298 | +function get_system_plugins($plugins) { |
2299 | + $inst_system_plugins = array(); | |
2300 | + | |
2301 | + if (sizeof($plugins)) { | |
2302 | + foreach($plugins as $plugin) { | |
2303 | + if (is_system_plugin($plugin)) { | |
2304 | + $inst_system_plugins[] = $plugin; | |
2305 | + } | |
c9a520e2 ER |
2306 | + } |
2307 | + } | |
1c1c23da SP |
2308 | + |
2309 | + return $inst_system_plugins; | |
c9a520e2 ER |
2310 | +} |
2311 | + | |
1c1c23da SP |
2312 | + |
2313 | diff -Naur cacti-0.8.7g-old/poller.php cacti-0.8.7g/poller.php | |
2314 | --- cacti-0.8.7g-old/poller.php 2010-07-09 18:33:46.000000000 -0400 | |
2315 | +++ cacti-0.8.7g/poller.php 2010-07-09 18:34:11.000000000 -0400 | |
ac01d3f9 AZ |
2316 | @@ -108,6 +108,8 @@ |
2317 | pcntl_signal(SIGINT, "sig_handler"); | |
c9a520e2 ER |
2318 | } |
2319 | ||
2320 | +api_plugin_hook('poller_top'); | |
2321 | + | |
2322 | /* record the start time */ | |
2323 | list($micro,$seconds) = split(" ", microtime()); | |
2324 | $poller_start = $seconds + $micro; | |
ac01d3f9 | 2325 | @@ -304,6 +306,8 @@ |
c9a520e2 ER |
2326 | $total_procs = $concurrent_processes; |
2327 | } | |
2328 | ||
2329 | + $extra_args = api_plugin_hook_function ('poller_command_args', $extra_args); | |
2330 | + | |
2331 | /* Populate each execution file with appropriate information */ | |
2332 | foreach ($polling_hosts as $item) { | |
2333 | if ($host_count == 1) { | |
ac01d3f9 | 2334 | @@ -446,9 +450,11 @@ |
c9a520e2 ER |
2335 | |
2336 | /* sleep the appripriate amount of time */ | |
2337 | if ($poller_runs_completed < $poller_runs) { | |
2338 | + api_plugin_hook('poller_bottom'); | |
2339 | db_close(); | |
2340 | usleep($sleep_time * 1000000); | |
2341 | db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port); | |
2342 | + api_plugin_hook('poller_top'); | |
2343 | } | |
ac01d3f9 | 2344 | }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) { |
c9a520e2 | 2345 | cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER"); |
ac01d3f9 | 2346 | @@ -495,4 +501,6 @@ |
c9a520e2 ER |
2347 | echo " --debug|-d Output debug information. Similar to cacti's DEBUG logging level.\n\n"; |
2348 | } | |
2349 | ||
2350 | +api_plugin_hook('poller_bottom'); | |
2351 | + | |
2352 | ?> | |
1c1c23da SP |
2353 | diff -Naur cacti-0.8.7g-old/user_admin.php cacti-0.8.7g/user_admin.php |
2354 | --- cacti-0.8.7g-old/user_admin.php 2010-07-09 18:33:46.000000000 -0400 | |
2355 | +++ cacti-0.8.7g/user_admin.php 2010-07-09 18:34:11.000000000 -0400 | |
ac01d3f9 | 2356 | @@ -57,9 +57,11 @@ |
c9a520e2 ER |
2357 | break; |
2358 | ||
2359 | default: | |
2360 | - include_once("include/top_header.php"); | |
2361 | - user(); | |
2362 | - include_once("include/bottom_footer.php"); | |
2363 | + if (!api_plugin_hook_function('user_admin_action', get_request_var_request("action"))) { | |
2364 | + include_once("include/top_header.php"); | |
2365 | + user(); | |
2366 | + include_once("include/bottom_footer.php"); | |
2367 | + } | |
2368 | break; | |
2369 | } | |
2370 | ||
ac01d3f9 | 2371 | @@ -402,6 +404,7 @@ |
c9a520e2 ER |
2372 | $save["policy_graph_templates"] = form_input_validate(get_request_var_post("policy_graph_templates", get_request_var_post("_policy_graph_templates")), "policy_graph_templates", "", true, 3); |
2373 | $save["realm"] = get_request_var_post("realm", 0); | |
2374 | $save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3); | |
2375 | + $save = api_plugin_hook_function('user_admin_setup_sql_save', $save); | |
2376 | ||
2377 | if (!is_error_message()) { | |
2378 | $user_id = sql_save($save, "user_auth"); | |
ac01d3f9 | 2379 | @@ -444,6 +447,8 @@ |
c9a520e2 ER |
2380 | policy_hosts = " . get_request_var_post("policy_hosts") . ", |
2381 | policy_graph_templates = " . get_request_var_post("policy_graph_templates") . " | |
2382 | WHERE id = " . get_request_var_post("id")); | |
2383 | + } else { | |
2384 | + api_plugin_hook('user_admin_user_save'); | |
2385 | } | |
2386 | } | |
2387 | } | |
ac01d3f9 | 2388 | @@ -889,6 +894,8 @@ |
c9a520e2 ER |
2389 | $header_label = "[new]"; |
2390 | } | |
2391 | ||
2392 | + api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0)); | |
2393 | + | |
2394 | html_start_box("<strong>User Management</strong> $header_label", "100%", $colors["header"], "3", "center", ""); | |
2395 | ||
2396 | draw_edit_form(array( | |
1c1c23da SP |
2397 | diff -Naur cacti-0.8.7g-old/utilities.php cacti-0.8.7g/utilities.php |
2398 | --- cacti-0.8.7g-old/utilities.php 2010-07-09 18:33:46.000000000 -0400 | |
2399 | +++ cacti-0.8.7g/utilities.php 2010-07-09 18:34:11.000000000 -0400 | |
ac01d3f9 | 2400 | @@ -123,11 +123,14 @@ |
c9a520e2 ER |
2401 | include_once("./include/bottom_footer.php"); |
2402 | break; | |
2403 | default: | |
2404 | - include_once("./include/top_header.php"); | |
2405 | ||
2406 | - utilities(); | |
2407 | + if (!api_plugin_hook_function('utilities_action', $_REQUEST['action'])) { | |
2408 | + include_once('./include/top_header.php'); | |
2409 | ||
2410 | - include_once("./include/bottom_footer.php"); | |
2411 | + utilities(); | |
2412 | + | |
2413 | + include_once('./include/bottom_footer.php'); | |
2414 | + } | |
2415 | break; | |
2416 | } | |
2417 | ||
1c1c23da | 2418 | @@ -1644,6 +1647,8 @@ |
c9a520e2 ER |
2419 | |
2420 | <?php | |
2421 | ||
2422 | + api_plugin_hook('utilities_list'); | |
2423 | + | |
2424 | html_end_box(); | |
2425 | } | |
2426 |