Line 0
Link Here
|
|
|
1 |
<?php |
2 |
/* |
3 |
+-------------------------------------------------------------------------+ |
4 |
| Copyright (C) 2004-2010 The Cacti Group | |
5 |
| | |
6 |
| This program is free software; you can redistribute it and/or | |
7 |
| modify it under the terms of the GNU General Public License | |
8 |
| as published by the Free Software Foundation; either version 2 | |
9 |
| of the License, or (at your option) any later version. | |
10 |
| | |
11 |
| This program is distributed in the hope that it will be useful, | |
12 |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 |
| GNU General Public License for more details. | |
15 |
+-------------------------------------------------------------------------+ |
16 |
| Cacti: The Complete RRDTool-based Graphing Solution | |
17 |
+-------------------------------------------------------------------------+ |
18 |
| This code is designed, written, and maintained by the Cacti Group. See | |
19 |
| about.php and/or the AUTHORS file for specific developer information. | |
20 |
+-------------------------------------------------------------------------+ |
21 |
| http://www.cacti.net/ | |
22 |
+-------------------------------------------------------------------------+ |
23 |
*/ |
24 |
|
25 |
include("./include/auth.php"); |
26 |
|
27 |
define("MAX_DISPLAY_PAGES", 21); |
28 |
|
29 |
$actions = array("install" => "Install", |
30 |
"enable" => "Enable", |
31 |
"disable" => "Disable", |
32 |
"uninstall" => "Uninstall", |
33 |
// "check" => "Check" |
34 |
); |
35 |
|
36 |
$status_names = array( |
37 |
-2 => 'Disabled', |
38 |
-1 => 'Active', |
39 |
0 => 'Not Installed', |
40 |
1 => 'Active', |
41 |
2 => 'Awaiting Configuration', |
42 |
3 => 'Awaiting Upgrade', |
43 |
4 => 'Installed' |
44 |
); |
45 |
|
46 |
/* get the comprehensive list of plugins */ |
47 |
$pluginslist = retrieve_plugin_list(); |
48 |
|
49 |
/* Check to see if we are installing, etc... */ |
50 |
$modes = array('installold', 'uninstallold', 'install', 'uninstall', 'disable', 'enable', 'check', 'moveup', 'movedown'); |
51 |
|
52 |
if (isset($_GET['mode']) && in_array($_GET['mode'], $modes) && isset($_GET['id'])) { |
53 |
input_validate_input_regex(get_request_var("id"), "^([a-zA-Z0-9]+)$"); |
54 |
|
55 |
$mode = $_GET['mode']; |
56 |
$id = sanitize_search_string($_GET['id']); |
57 |
|
58 |
switch ($mode) { |
59 |
case 'installold': |
60 |
api_plugin_install_old($id); |
61 |
header("Location: plugins.php"); |
62 |
exit; |
63 |
break; |
64 |
case 'uninstallold': |
65 |
api_plugin_uninstall_old($id); |
66 |
header("Location: plugins.php"); |
67 |
exit; |
68 |
break; |
69 |
case 'install': |
70 |
api_plugin_install($id); |
71 |
header("Location: plugins.php"); |
72 |
exit; |
73 |
break; |
74 |
case 'uninstall': |
75 |
if (!in_array($id, $pluginslist)) break; |
76 |
api_plugin_uninstall($id); |
77 |
header("Location: plugins.php"); |
78 |
exit; |
79 |
break; |
80 |
case 'disable': |
81 |
if (!in_array($id, $pluginslist)) break; |
82 |
api_plugin_disable($id); |
83 |
header("Location: plugins.php"); |
84 |
exit; |
85 |
break; |
86 |
case 'enable': |
87 |
if (!in_array($id, $pluginslist)) break; |
88 |
api_plugin_enable($id); |
89 |
header("Location: plugins.php"); |
90 |
exit; |
91 |
break; |
92 |
case 'check': |
93 |
if (!in_array($id, $pluginslist)) break; |
94 |
break; |
95 |
case 'moveup': |
96 |
if (!in_array($id, $pluginslist)) break; |
97 |
if (is_system_plugin($id)) break; |
98 |
api_plugin_moveup($id); |
99 |
header("Location: plugins.php"); |
100 |
exit; |
101 |
break; |
102 |
case 'movedown': |
103 |
if (!in_array($id, $pluginslist)) break; |
104 |
if (is_system_plugin($id)) break; |
105 |
api_plugin_movedown($id); |
106 |
header("Location: plugins.php"); |
107 |
exit; |
108 |
break; |
109 |
} |
110 |
} |
111 |
|
112 |
function retrieve_plugin_list () { |
113 |
$pluginslist = array(); |
114 |
$temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name'); |
115 |
foreach ($temp as $t) { |
116 |
$pluginslist[] = $t['directory']; |
117 |
} |
118 |
return $pluginslist; |
119 |
} |
120 |
|
121 |
include("./include/top_header.php"); |
122 |
|
123 |
update_show_current(); |
124 |
|
125 |
include("./include/bottom_footer.php"); |
126 |
|
127 |
function api_plugin_install_old ($plugin) { |
128 |
global $config; |
129 |
if (!file_exists($config['base_path'] . "/plugins/$plugin/setup.php")) { |
130 |
return false; |
131 |
} |
132 |
$oldplugins = read_config_option('oldplugins'); |
133 |
if (strlen(trim($oldplugins))) { |
134 |
$oldplugins = explode(',', $oldplugins); |
135 |
}else{ |
136 |
$oldplugins = array(); |
137 |
} |
138 |
if (!in_array($plugin, $oldplugins)) { |
139 |
include_once($config['base_path'] . "/plugins/$plugin/setup.php"); |
140 |
$function = 'plugin_init_' . $plugin; |
141 |
if (function_exists($function)){ |
142 |
$oldplugins[] = $plugin; |
143 |
$oldplugins = implode(',', $oldplugins); |
144 |
set_config_option('oldplugins', $oldplugins); |
145 |
unset($_SESSION['sess_config_array']['oldplugins']); |
146 |
return true; |
147 |
} else { |
148 |
return false; |
149 |
} |
150 |
} |
151 |
return false; |
152 |
} |
153 |
|
154 |
function api_plugin_uninstall_old ($plugin) { |
155 |
global $config; |
156 |
$oldplugins = read_config_option('oldplugins'); |
157 |
if (strlen(trim($oldplugins))) { |
158 |
$oldplugins = explode(',', $oldplugins); |
159 |
}else{ |
160 |
$oldplugins = array(); |
161 |
} |
162 |
if (!empty($oldplugins)) { |
163 |
if (in_array($plugin, $oldplugins)) { |
164 |
for ($a = 0; $a < count($oldplugins); $a++) { |
165 |
if ($oldplugins[$a] == $plugin) { |
166 |
unset($oldplugins[$a]); |
167 |
break; |
168 |
} |
169 |
} |
170 |
$oldplugins = implode(',', $oldplugins); |
171 |
set_config_option('oldplugins', $oldplugins); |
172 |
unset($_SESSION['sess_config_array']['oldplugins']); |
173 |
return true; |
174 |
} |
175 |
} |
176 |
return false; |
177 |
} |
178 |
|
179 |
function update_show_updates () { |
180 |
global $pluginslist, $colors, $config, $plugin_architecture; |
181 |
|
182 |
$cinfo = array(); |
183 |
sort($pluginslist); |
184 |
|
185 |
$cinfo = update_get_plugin_info (); |
186 |
|
187 |
$x = 0; |
188 |
|
189 |
$info = update_get_cached_plugin_info(); |
190 |
|
191 |
$cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ; |
192 |
if (isset($cinfo['cacti_plugin_arch']['version'])) { |
193 |
$archnew = update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']); |
194 |
} else { |
195 |
$archnew = 0; |
196 |
} |
197 |
|
198 |
if ($cactinew) { |
199 |
$x++; |
200 |
print "<tr><td width='25%' valign=top><table width='100%'>"; |
201 |
html_header(array("Cacti"), 2); |
202 |
form_alternate_row_color($colors["alternate"],$colors["light"], 0); |
203 |
print "<td width='25%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr>"; |
204 |
form_alternate_row_color($colors["alternate"],$colors["light"], 0); |
205 |
print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti']['changes']) . "</td></tr></table>"; |
206 |
} |
207 |
if (isset($plugin_architecture['version']) && $archnew) { |
208 |
$x++; |
209 |
print "<table width='100%'>"; |
210 |
html_header(array("Plugin Architecture"), 2); |
211 |
form_alternate_row_color($colors["alternate"],$colors["light"], 0); |
212 |
print "<td width='25%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td>"; |
213 |
form_alternate_row_color($colors["alternate"],$colors["light"], 0); |
214 |
print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti_plugin_arch']['changes']) . "</td></tr></table>"; |
215 |
} |
216 |
print "<table width='100%' cellspacing=0 cellpadding=3>"; |
217 |
|
218 |
foreach ($pluginslist as $plugin) { |
219 |
if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) { |
220 |
$x++; |
221 |
print "<table width='100%'>"; |
222 |
html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2); |
223 |
form_alternate_row_color($colors["alternate"],$colors["light"], 0); |
224 |
print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>"; |
225 |
form_alternate_row_color($colors["alternate"],$colors["light"], 0); |
226 |
print "<td><strong>Version:</strong></td><td>" . $info[$plugin]['version'] . "</td>"; |
227 |
form_alternate_row_color($colors["alternate"],$colors["light"], 0); |
228 |
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>"; |
229 |
form_alternate_row_color($colors["alternate"],$colors["light"], 0); |
230 |
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>"; |
231 |
form_alternate_row_color($colors["alternate"],$colors["light"], 0); |
232 |
print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info[$plugin]['changes']) . "</td>"; |
233 |
|
234 |
print "</tr></table>"; |
235 |
} |
236 |
} |
237 |
if ($x == 0) |
238 |
print "<br><center><b>There are currently no Updates!</b></center><br>"; |
239 |
print "</table>"; |
240 |
html_end_box(TRUE); |
241 |
} |
242 |
|
243 |
function update_check_if_newer() { |
244 |
return false; |
245 |
} |
246 |
|
247 |
function plugins_temp_table_exists($table) { |
248 |
return sizeof(db_fetch_row("SHOW TABLES LIKE '$table'")); |
249 |
} |
250 |
|
251 |
function plugins_load_temp_table() { |
252 |
global $config, $plugins; |
253 |
|
254 |
$pluginslist = retrieve_plugin_list(); |
255 |
|
256 |
if (isset($_SESSION["plugin_temp_table"])) { |
257 |
$table = $_SESSION["plugin_temp_table"]; |
258 |
}else{ |
259 |
$table = "plugin_temp_table_" . rand(); |
260 |
} |
261 |
|
262 |
while (true) { |
263 |
if (!plugins_temp_table_exists($table)) { |
264 |
$_SESSION["plugin_temp_table"] = $table; |
265 |
db_execute("CREATE TEMPORARY TABLE $table LIKE plugin_config"); |
266 |
db_execute("INSERT INTO $table SELECT * FROM plugin_config"); |
267 |
break; |
268 |
}else{ |
269 |
$table = "plugin_temp_table_" . rand(); |
270 |
} |
271 |
} |
272 |
|
273 |
$path = $config['base_path'] . '/plugins/'; |
274 |
$dh = opendir($path); |
275 |
while (($file = readdir($dh)) !== false) { |
276 |
if ((is_dir("$path/$file")) && (file_exists("$path/$file/setup.php")) && (!in_array($file, $pluginslist))) { |
277 |
include_once("$path/$file/setup.php"); |
278 |
if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) { |
279 |
$function = $file . '_version'; |
280 |
$cinfo[$file] = $function(); |
281 |
if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown'; |
282 |
if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated'; |
283 |
if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage']; |
284 |
if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['longname'] = ucfirst($file); |
285 |
$cinfo[$file]['status'] = -2; |
286 |
if (in_array($file, $plugins)) { |
287 |
$cinfo[$file]['status'] = -1; |
288 |
} |
289 |
db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version) |
290 |
VALUES ('" . |
291 |
$file . "', '" . |
292 |
$cinfo[$file]['longname'] . "', '" . |
293 |
$cinfo[$file]['status'] . "', '" . |
294 |
$cinfo[$file]['author'] . "', '" . |
295 |
$cinfo[$file]['homepage'] . "', '" . |
296 |
$cinfo[$file]['version'] . "')"); |
297 |
$pluginslist[] = $file; |
298 |
} elseif (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) { |
299 |
$function = $file . '_version'; |
300 |
$cinfo[$file] = $function(); |
301 |
$cinfo[$file]['status'] = 0; |
302 |
if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown'; |
303 |
if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated'; |
304 |
if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage']; |
305 |
if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['homepage'] = ucfirst($file); |
306 |
|
307 |
/* see if it's been installed as old, if so, remove from oldplugins array and session */ |
308 |
$oldplugins = read_config_option("oldplugins"); |
309 |
if (substr_count($oldplugins, $file)) { |
310 |
$oldplugins = str_replace($file, "", $oldplugins); |
311 |
$oldplugins = str_replace(",,", ",", $oldplugins); |
312 |
$oldplugins = trim($oldplugins, ","); |
313 |
set_config_option('oldplugins', $oldplugins); |
314 |
$_SESSION['sess_config_array']['oldplugins'] = $oldplugins; |
315 |
} |
316 |
|
317 |
db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version) |
318 |
VALUES ('" . |
319 |
$file . "', '" . |
320 |
$cinfo[$file]['longname'] . "', '" . |
321 |
$cinfo[$file]['status'] . "', '" . |
322 |
$cinfo[$file]['author'] . "', '" . |
323 |
$cinfo[$file]['homepage'] . "', '" . |
324 |
$cinfo[$file]['version'] . "')"); |
325 |
$pluginslist[] = $file; |
326 |
} |
327 |
} |
328 |
} |
329 |
closedir($dh); |
330 |
|
331 |
return $table; |
332 |
} |
333 |
|
334 |
function update_show_current () { |
335 |
global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names, $actions; |
336 |
|
337 |
/* ================= input validation ================= */ |
338 |
input_validate_input_number(get_request_var_request("page")); |
339 |
/* ==================================================== */ |
340 |
|
341 |
/* clean up search string */ |
342 |
if (isset($_REQUEST["filter"])) { |
343 |
$_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); |
344 |
} |
345 |
|
346 |
/* clean up sort_column */ |
347 |
if (isset($_REQUEST["sort_column"])) { |
348 |
$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); |
349 |
} |
350 |
|
351 |
/* clean up search string */ |
352 |
if (isset($_REQUEST["sort_direction"])) { |
353 |
$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); |
354 |
} |
355 |
|
356 |
/* if the user pushed the 'clear' button */ |
357 |
if (isset($_REQUEST["clear_x"])) { |
358 |
kill_session_var("sess_plugins_filter"); |
359 |
kill_session_var("sess_plugins_sort_column"); |
360 |
kill_session_var("sess_plugins_sort_direction"); |
361 |
|
362 |
unset($_REQUEST["page"]); |
363 |
unset($_REQUEST["filter"]); |
364 |
unset($_REQUEST["sort_column"]); |
365 |
unset($_REQUEST["sort_direction"]); |
366 |
$_REQUEST["page"] = 1; |
367 |
} |
368 |
|
369 |
/* remember these search fields in session vars so we don't have to keep passing them around */ |
370 |
load_current_session_value("filter", "sess_plugins_filter", ""); |
371 |
load_current_session_value("sort_column", "sess_plugins_sort_column", "name"); |
372 |
load_current_session_value("sort_direction", "sess_plugins_sort_direction", "ASC"); |
373 |
load_current_session_value("page", "sess_plugins_current_page", "1"); |
374 |
|
375 |
$table = plugins_load_temp_table(); |
376 |
|
377 |
html_start_box("<strong>Plugin Management</strong> (Cacti Version: " . $config["cacti_version"] . |
378 |
(isset($plugin_architecture['version']) ? ", Plugin Architecture Version: " . $plugin_architecture['version']:"") . |
379 |
")", "100%", $colors["header"], "3", "center", ""); |
380 |
|
381 |
?> |
382 |
<tr bgcolor="#<?php print $colors['panel'];?>"> |
383 |
<td class="noprint"> |
384 |
<form name="form_plugins" method="get" action="plugins.php"> |
385 |
<table width="100%" cellpadding="0" cellspacing="0"> |
386 |
<tr class="noprint"> |
387 |
<td nowrap style='white-space: nowrap;' width="50"> |
388 |
Search: |
389 |
</td> |
390 |
<td width="1"> |
391 |
<input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>"> |
392 |
</td> |
393 |
<td nowrap style='white-space: nowrap;'> |
394 |
<input type="submit" value="Go" title="Set/Refresh Filters"> |
395 |
<input type="submit" name="clear_x" value="Clear" title="Clear Filters"> |
396 |
</td> |
397 |
</tr> |
398 |
</table> |
399 |
<input type='hidden' name='page' value='1'> |
400 |
</form> |
401 |
</td> |
402 |
</tr> |
403 |
<?php |
404 |
|
405 |
html_end_box(); |
406 |
|
407 |
/* print checkbox form for validation */ |
408 |
print "<form name='chk' method='post' action='plugins.php'>\n"; |
409 |
|
410 |
html_start_box("", "100%", $colors["header"], "3", "center", ""); |
411 |
|
412 |
/* form the 'where' clause for our main sql query */ |
413 |
$sql_where = "WHERE ($table.name LIKE '%%" . get_request_var_request("filter") . "%%')"; |
414 |
|
415 |
if (get_request_var_request("sort_column") == "version") { |
416 |
$sortc = "version+0"; |
417 |
}else{ |
418 |
$sortc = get_request_var_request("sort_column"); |
419 |
} |
420 |
|
421 |
if (get_request_var_request("sort_column") == "id") { |
422 |
$sortd = "ASC"; |
423 |
}else{ |
424 |
$sortd = get_request_var_request("sort_direction"); |
425 |
} |
426 |
|
427 |
$total_rows = db_fetch_cell("SELECT |
428 |
count(*) |
429 |
FROM $table |
430 |
$sql_where"); |
431 |
|
432 |
$plugins = db_fetch_assoc("SELECT * |
433 |
FROM $table |
434 |
$sql_where |
435 |
ORDER BY " . $sortc . " " . $sortd . " |
436 |
LIMIT " . (read_config_option("num_rows_device")*(get_request_var_request("page")-1)) . "," . read_config_option("num_rows_device")); |
437 |
|
438 |
db_execute("DROP TABLE $table"); |
439 |
|
440 |
/* generate page list */ |
441 |
$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")); |
442 |
|
443 |
if ($total_rows == 0) { |
444 |
$nav = "<tr bgcolor='#" . $colors["header"] . "'> |
445 |
<td colspan='9'> |
446 |
<table width='100%' cellspacing='0' cellpadding='0' border='0'> |
447 |
<tr> |
448 |
<td align='center' class='textHeaderDark'> |
449 |
No Plugins Found |
450 |
</td>\n |
451 |
</tr> |
452 |
</table> |
453 |
</td> |
454 |
</tr>\n"; |
455 |
}elseif ($total_rows < read_config_option("num_rows_device")) { |
456 |
$nav = "<tr bgcolor='#" . $colors["header"] . "'> |
457 |
<td colspan='9'> |
458 |
<table width='100%' cellspacing='0' cellpadding='0' border='0'> |
459 |
<tr> |
460 |
<td align='center' class='textHeaderDark'> |
461 |
Showing All $total_rows Rows |
462 |
</td>\n |
463 |
</tr> |
464 |
</table> |
465 |
</td> |
466 |
</tr>\n"; |
467 |
}else{ |
468 |
$nav = "<tr bgcolor='#" . $colors["header"] . "'> |
469 |
<td colspan='9'> |
470 |
<table width='100%' cellspacing='0' cellpadding='0' border='0'> |
471 |
<tr> |
472 |
<td align='left' class='textHeaderDark'> |
473 |
<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> |
474 |
</td>\n |
475 |
<td align='center' class='textHeaderDark'> |
476 |
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] |
477 |
</td>\n |
478 |
<td align='right' class='textHeaderDark'> |
479 |
<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> |
480 |
</td>\n |
481 |
</tr> |
482 |
</table> |
483 |
</td> |
484 |
</tr>\n"; |
485 |
} |
486 |
|
487 |
print $nav; |
488 |
|
489 |
$display_text = array( |
490 |
"nosort" => array("Actions", ""), |
491 |
"directory" => array("Name", "ASC"), |
492 |
"id" => array("Load Order", "ASC"), |
493 |
"name" => array("Description", "ASC"), |
494 |
"nosort1" => array("Type", "ASC"), |
495 |
"status" => array("Status", "ASC"), |
496 |
"author" => array("Author", "ASC"), |
497 |
"webpage" => array("Web Page", "ASC"), |
498 |
"version" => array("Version", "ASC")); |
499 |
|
500 |
html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), 1); |
501 |
|
502 |
$i = 0; |
503 |
if (sizeof($plugins)) { |
504 |
if (get_request_var_request("sort_column") == "id") { |
505 |
$inst_system_plugins = get_system_plugins($plugins); |
506 |
if (sizeof($inst_system_plugins)) { |
507 |
foreach($inst_system_plugins as $plugin) { |
508 |
form_alternate_row_color($colors["alternate"], $colors["light"], $i); $i++; |
509 |
print format_plugin_row($plugin, false, false, true); |
510 |
} |
511 |
} |
512 |
} |
513 |
|
514 |
$j = 0; |
515 |
foreach ($plugins as $plugin) { |
516 |
if ((isset($plugins[$j+1]) && $plugins[$j+1]['status'] < 0) || (!isset($plugins[$j+1]))) { |
517 |
$last_plugin = true; |
518 |
}else{ |
519 |
$last_plugin = false; |
520 |
} |
521 |
if ($plugin['status'] <= 0 || is_system_plugin($plugin) || (get_request_var_request('sort_column') != 'id')) { |
522 |
$load_ordering = false; |
523 |
}else{ |
524 |
$load_ordering = true; |
525 |
} |
526 |
|
527 |
if (get_request_var_request("sort_column") == "id") { |
528 |
if (!is_system_plugin($plugin)) { |
529 |
form_alternate_row_color($colors["alternate"], $colors["light"], $i); |
530 |
print format_plugin_row($plugin, $last_plugin, $load_ordering, false); |
531 |
$i++; |
532 |
} |
533 |
}else{ |
534 |
form_alternate_row_color($colors["alternate"], $colors["light"], $i); |
535 |
print format_plugin_row($plugin, $last_plugin, $load_ordering, is_system_plugin($plugin)); |
536 |
$i++; |
537 |
} |
538 |
|
539 |
$j++; |
540 |
} |
541 |
|
542 |
print $nav; |
543 |
}else{ |
544 |
print "<tr><td><em>No Plugins Found</em></td></tr>"; |
545 |
} |
546 |
|
547 |
html_end_box(false); |
548 |
|
549 |
html_start_box("", "100%", $colors["header"], "3", "center", ""); |
550 |
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>"; |
551 |
html_end_box(); |
552 |
|
553 |
print "</form>\n"; |
554 |
} |
555 |
|
556 |
function format_plugin_row($plugin, $last_plugin, $include_ordering, $system_plugin) { |
557 |
global $status_names; |
558 |
static $first_plugin = true; |
559 |
|
560 |
$row = plugin_actions($plugin); |
561 |
$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>"; |
562 |
if ($include_ordering) { |
563 |
$row .= "<td style='white-space:nowrap;'>"; |
564 |
if (!$first_plugin) { |
565 |
$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>"; |
566 |
}else{ |
567 |
$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>"; |
568 |
} |
569 |
if (!$last_plugin) { |
570 |
$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>"; |
571 |
}else{ |
572 |
$row .= "<a href='#' title='Can Increase Load Order' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'></a>"; |
573 |
} |
574 |
$row .= "</td>\n"; |
575 |
}else{ |
576 |
$row .= "<td></td>\n"; |
577 |
} |
578 |
|
579 |
$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"; |
580 |
$row .= "<td style='white-space:nowrap;'>" . ($system_plugin ? "System": ($plugin['status'] < 0 ? "Old PIA":"General")) . "</td>\n"; |
581 |
$row .= "<td style='white-space:nowrap;'>" . $status_names[$plugin["status"]] . "</td>\n"; |
582 |
$row .= "<td style='white-space:nowrap;'>" . $plugin["author"] . "</td>\n"; |
583 |
$row .= "<td><a href='" . htmlspecialchars($plugin["webpage"]) . "'>" . htmlspecialchars($plugin["webpage"]) . "</a></td>\n"; |
584 |
$row .= "<td>" . $plugin["version"] . "</td>\n"; |
585 |
$row .= "</tr>\n"; |
586 |
|
587 |
if ($include_ordering) { |
588 |
$first_plugin = false; |
589 |
} |
590 |
|
591 |
return $row; |
592 |
} |
593 |
|
594 |
function plugin_actions($plugin) { |
595 |
$link = "<td>"; |
596 |
switch ($plugin['status']) { |
597 |
case "-2": // Old PA Not Installed |
598 |
$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>"; |
599 |
$link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>"; |
600 |
break; |
601 |
case "-1": // Old PA Currently Active |
602 |
$oldplugins = read_config_option('oldplugins'); |
603 |
if (strlen(trim($oldplugins))) { |
604 |
$oldplugins = explode(',', $oldplugins); |
605 |
}else{ |
606 |
$oldplugins = array(); |
607 |
} |
608 |
if (in_array($plugin['directory'], $oldplugins)) { |
609 |
$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>"; |
610 |
} else { |
611 |
$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>"; |
612 |
} |
613 |
$link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>"; |
614 |
break; |
615 |
case "0": // Not Installed |
616 |
$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>"; |
617 |
$link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>"; |
618 |
break; |
619 |
case "1": // Currently Active |
620 |
$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>"; |
621 |
$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>"; |
622 |
break; |
623 |
case "4": // Installed but not active |
624 |
$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>"; |
625 |
$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>"; |
626 |
break; |
627 |
default: // Old PIA |
628 |
$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>"; |
629 |
$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>"; |
630 |
break; |
631 |
} |
632 |
$link .= "</td>"; |
633 |
|
634 |
return $link; |
635 |
} |
636 |
|
637 |
function is_system_plugin($plugin) { |
638 |
global $plugins_system; |
639 |
|
640 |
if (is_array($plugin)) { |
641 |
$plugin = $plugin["directory"]; |
642 |
} |
643 |
|
644 |
if (!in_array($plugin, $plugins_system)) { |
645 |
return false; |
646 |
}else{ |
647 |
return true; |
648 |
} |
649 |
} |
650 |
|
651 |
function get_system_plugins($plugins) { |
652 |
$inst_system_plugins = array(); |
653 |
|
654 |
if (sizeof($plugins)) { |
655 |
foreach($plugins as $plugin) { |
656 |
if (is_system_plugin($plugin)) { |
657 |
$inst_system_plugins[] = $plugin; |
658 |
} |
659 |
} |
660 |
} |
661 |
|
662 |
return $inst_system_plugins; |
663 |
} |
664 |
|
665 |
|