forked from Cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugins.php
591 lines (524 loc) · 21.7 KB
/
plugins.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2016 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
include('./include/auth.php');
$actions = array('install' => 'Install',
'enable' => 'Enable',
'disable' => 'Disable',
'uninstall' => 'Uninstall',
// 'check' => 'Check'
);
$status_names = array(
-2 => 'Disabled',
-1 => 'Active',
0 => 'Not Installed',
1 => 'Active',
2 => 'Awaiting Configuration',
3 => 'Awaiting Upgrade',
4 => 'Installed'
);
/* get the comprehensive list of plugins */
$pluginslist = retrieve_plugin_list();
/* Check to see if we are installing, etc... */
$modes = array('installold', 'uninstallold', 'install', 'uninstall', 'disable', 'enable', 'check', 'moveup', 'movedown');
if (isset_request_var('mode') && in_array(get_request_var('mode'), $modes) && isset_request_var('id')) {
get_filter_request_var('id', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9]+)$/')));
$mode = get_request_var('mode');
$id = sanitize_search_string(get_request_var('id'));
switch ($mode) {
case 'installold':
if (!in_array($id, $plugins_integrated)) {
api_plugin_install_old($id);
}
header('Location: plugins.php');
exit;
break;
case 'uninstallold':
api_plugin_uninstall_old($id);
header('Location: plugins.php');
exit;
break;
case 'install':
if (!in_array($id, $plugins_integrated)) {
api_plugin_install($id);
}
if ($_SESSION['sess_plugins_state'] != '-3') {
header('Location: plugins.php?state=5');
}else{
header('Location: plugins.php');
}
exit;
break;
case 'uninstall':
if (!in_array($id, $pluginslist)) break;
api_plugin_uninstall($id);
header('Location: plugins.php');
exit;
break;
case 'disable':
if (!in_array($id, $pluginslist)) break;
api_plugin_disable($id);
header('Location: plugins.php');
exit;
break;
case 'enable':
if (!in_array($id, $pluginslist)) break;
if (!in_array($id, $plugins_integrated)) {
api_plugin_enable($id);
}
header('Location: plugins.php');
exit;
break;
case 'check':
if (!in_array($id, $pluginslist)) break;
break;
case 'moveup':
if (!in_array($id, $pluginslist)) break;
if (in_array($id, $plugins_integrated)) break;
api_plugin_moveup($id);
header('Location: plugins.php');
exit;
break;
case 'movedown':
if (!in_array($id, $pluginslist)) break;
if (in_array($id, $plugins_integrated)) break;
api_plugin_movedown($id);
header('Location: plugins.php');
exit;
break;
}
}
function retrieve_plugin_list () {
$pluginslist = array();
$temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name');
foreach ($temp as $t) {
$pluginslist[] = $t['directory'];
}
return $pluginslist;
}
top_header();
update_show_current();
bottom_footer();
function api_plugin_install_old ($plugin) {
global $config;
if (!file_exists($config['base_path'] . "/plugins/$plugin/setup.php")) {
return false;
}
$oldplugins = read_config_option('oldplugins');
if (strlen(trim($oldplugins))) {
$oldplugins = explode(',', $oldplugins);
}else{
$oldplugins = array();
}
if (!in_array($plugin, $oldplugins)) {
include_once($config['base_path'] . "/plugins/$plugin/setup.php");
$function = 'plugin_init_' . $plugin;
if (function_exists($function)){
$oldplugins[] = $plugin;
$oldplugins = implode(',', $oldplugins);
set_config_option('oldplugins', $oldplugins);
unset($_SESSION['sess_config_array']['oldplugins']);
return true;
} else {
return false;
}
}
return false;
}
function api_plugin_uninstall_old ($plugin) {
global $config;
$oldplugins = read_config_option('oldplugins');
if (strlen(trim($oldplugins))) {
$oldplugins = explode(',', $oldplugins);
}else{
$oldplugins = array();
}
if (!empty($oldplugins)) {
if (in_array($plugin, $oldplugins)) {
for ($a = 0; $a < count($oldplugins); $a++) {
if ($oldplugins[$a] == $plugin) {
unset($oldplugins[$a]);
break;
}
}
$oldplugins = implode(',', $oldplugins);
set_config_option('oldplugins', $oldplugins);
unset($_SESSION['sess_config_array']['oldplugins']);
return true;
}
}
return false;
}
function plugins_temp_table_exists($table) {
return sizeof(db_fetch_row("SHOW TABLES LIKE '$table'"));
}
function plugins_load_temp_table() {
global $config, $plugins, $plugins_integrated;
$pluginslist = retrieve_plugin_list();
if (isset($_SESSION['plugin_temp_table'])) {
$table = $_SESSION['plugin_temp_table'];
}else{
$table = 'plugin_temp_table_' . rand();
}
$x = 0;
while ($x < 30) {
if (!plugins_temp_table_exists($table)) {
$_SESSION['plugin_temp_table'] = $table;
db_execute("CREATE TEMPORARY TABLE IF NOT EXISTS $table LIKE plugin_config");
db_execute("TRUNCATE $table");
db_execute("INSERT INTO $table SELECT * FROM plugin_config");
break;
}else{
$table = 'plugin_temp_table_' . rand();
}
$x++;
}
$path = $config['base_path'] . '/plugins/';
$dh = opendir($path);
if ($dh !== false) {
while (($file = readdir($dh)) !== false) {
if (is_dir("$path/$file") && file_exists("$path/$file/setup.php") && !in_array($file, $pluginslist) && !in_array($file, $plugins_integrated)) {
include_once("$path/$file/setup.php");
if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) {
$function = $file . '_version';
$cinfo[$file] = $function();
if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown';
if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['longname'] = ucfirst($file);
$cinfo[$file]['status'] = -2;
if (in_array($file, $plugins)) {
$cinfo[$file]['status'] = -1;
}
db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
VALUES ('" .
$file . "', '" .
$cinfo[$file]['longname'] . "', '" .
$cinfo[$file]['status'] . "', '" .
$cinfo[$file]['author'] . "', '" .
$cinfo[$file]['homepage'] . "', '" .
$cinfo[$file]['version'] . "')");
$pluginslist[] = $file;
} elseif (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
$function = $file . '_version';
$cinfo[$file] = $function();
$cinfo[$file]['status'] = 0;
if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown';
if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['homepage'] = ucfirst($file);
/* see if it's been installed as old, if so, remove from oldplugins array and session */
$oldplugins = read_config_option('oldplugins');
if (substr_count($oldplugins, $file)) {
$oldplugins = str_replace($file, '', $oldplugins);
$oldplugins = str_replace(',,', ',', $oldplugins);
$oldplugins = trim($oldplugins, ',');
set_config_option('oldplugins', $oldplugins);
$_SESSION['sess_config_array']['oldplugins'] = $oldplugins;
}
db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
VALUES ('" .
$file . "', '" .
$cinfo[$file]['longname'] . "', '" .
$cinfo[$file]['status'] . "', '" .
$cinfo[$file]['author'] . "', '" .
$cinfo[$file]['homepage'] . "', '" .
$cinfo[$file]['version'] . "')");
$pluginslist[] = $file;
}
}
}
closedir($dh);
}
return $table;
}
function update_show_current () {
global $plugins, $pluginslist, $config, $status_names, $actions, $item_rows;
/* ================= input validation and session storage ================= */
$filters = array(
'rows' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => read_config_option('num_rows_table')
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'sort_column' => array(
'filter' => FILTER_CALLBACK,
'default' => 'name',
'options' => array('options' => 'sanitize_search_string')
),
'sort_direction' => array(
'filter' => FILTER_CALLBACK,
'default' => 'ASC',
'options' => array('options' => 'sanitize_search_string')
),
'state' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-3'
)
);
validate_store_request_vars($filters, 'sess_plugins');
/* ================= input validation ================= */
$table = plugins_load_temp_table();
?>
<script type="text/javascript">
function applyFilter() {
strURL = 'plugins.php?filter='+$('#filter').val()+'&rows='+$('#rows').val()+'&page='+$('#page').val()+'&state='+$('#state').val()+'&header=false';
loadPageNoHeader(strURL);
}
function clearFilter() {
strURL = 'plugins.php?clear=1&header=false';
loadPageNoHeader(strURL);
}
$(function() {
$('#refresh').click(function() {
applyFilter();
});
$('#clear').click(function() {
clearFilter();
});
$('#form_plugins').submit(function(event) {
event.preventDefault();
applyFilter();
});
});
</script>
<?php
html_start_box('Plugin Management (Cacti Version: ' . $config['cacti_version'] . ')', '100%', '', '3', 'center', '');
?>
<tr class='even noprint'>
<td class='noprint'>
<form id='form_plugins' method='get' action='plugins.php'>
<table class='filterTable'>
<tr class='noprint'>
<td>
Search
</td>
<td>
<input id='filter' type='text' name='filter' size='25' value='<?php print get_request_var('filter');?>'>
</td>
<td>
Status
</td>
<td>
<select id='state' name='state' onChange='applyFilter()'>
<option value='-3'<?php if (get_request_var('state') == '-3') {?> selected<?php }?>>All</option>
<option value='1'<?php if (get_request_var('state') == '1') {?> selected<?php }?>>Active</option>
<option value='4'<?php if (get_request_var('state') == '4') {?> selected<?php }?>>Installed</option>
<option value='5'<?php if (get_request_var('state') == '5') {?> selected<?php }?>>Active/Installed</option>
<option value='2'<?php if (get_request_var('state') == '2') {?> selected<?php }?>>Configuration Issues</option>
<option value='0'<?php if (get_request_var('state') == '0') {?> selected<?php }?>>Not Installed</option>
<option value='-1'<?php if (get_request_var('state') == '-1') {?> selected<?php }?>>Legacy Installed</option>
<option value='-2'<?php if (get_request_var('state') == '-2') {?> selected<?php }?>>Legacy Not Intalled</option>
</select>
</td>
<td>
Plugins
</td>
<td>
<select id='rows' name='rows' onChange='applyFilter()'>
<?php
if (sizeof($item_rows) > 0) {
foreach ($item_rows as $key => $value) {
print "<option value='" . $key . "'"; if (get_request_var('rows') == $key) { print ' selected'; } print '>' . htmlspecialchars($value) . "</option>\n";
}
}
?>
</select>
</td>
<td>
<input type='button' id='refresh' value='Go' title='Set/Refresh Filters'>
</td>
<td>
<input type='button' id='clear' value='Clear' title='Clear Filters'>
</td>
</tr>
</table>
<input type='hidden' id='page' name='page' value='<?php print get_request_var('page');?>'>
</form>
</td>
</tr>
<?php
html_end_box();
form_start('plugins.php', 'chk');
html_start_box('', '100%', '', '3', 'center', '');
$sql_where = '';
/* form the 'where' clause for our main sql query */
if (get_request_var('filter') != '') {
$sql_where = "WHERE ($table.name LIKE '%" . get_request_var('filter') . "%')";
}
if (get_request_var('state') > -3) {
if (get_request_var('state') == 5) {
$sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' status IN(1,4)';
}else{
$sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' status=' . get_request_var('state');
}
}
if (get_request_var('sort_column') == 'version') {
$sortc = 'version+0';
}else{
$sortc = get_request_var('sort_column');
}
if (get_request_var('sort_column') == 'id') {
$sortd = 'ASC';
}else{
$sortd = get_request_var('sort_direction');
}
if (get_request_var('rows') == '-1') {
$rows = read_config_option('num_rows_table');
}else{
$rows = get_request_var('rows');
}
$total_rows = db_fetch_cell("SELECT
count(*)
FROM $table
$sql_where");
$plugins = db_fetch_assoc("SELECT *
FROM $table
$sql_where
ORDER BY " . $sortc . ' ' . $sortd . '
LIMIT ' . ($rows*(get_request_var('page')-1)) . ',' . $rows);
db_execute("DROP TABLE $table");
$nav = html_nav_bar('plugins.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 8, 'Plugins', 'page', 'main');
print $nav;
$display_text = array(
'nosort' => array('display' => 'Actions', 'align' => 'left', 'sort' => '', 'tip' => 'Actions available include "Install", "Activate", "Disable", "Enable", "Uninstall".'),
'directory' => array('display' => 'Plugin Name', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The name for this Plugin. The name is controlled by the directory it resides in.'),
'id' => array('display' => 'Load Order', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The load order of the Plugin. You can change the load order by first sorting by it, then moving a Plugin either up or down.'),
'name' => array('display' => 'Plugin Description', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'A description that the Plugins author has given to the Plugin.'),
'version' => array('display' => 'Version', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The version of this Plugin.'),
'status' => array('display' => 'Status', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The status of this Plugin.'),
'author' => array('display' => 'Author', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The author of this Plugin.'));
html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), 1);
$i = 0;
if (sizeof($plugins)) {
$j = 0;
foreach ($plugins as $plugin) {
if ((isset($plugins[$j+1]) && $plugins[$j+1]['status'] < 0) || (!isset($plugins[$j+1]))) {
$last_plugin = true;
}else{
$last_plugin = false;
}
if ($plugin['status'] <= 0 || (get_request_var('sort_column') != 'id')) {
$load_ordering = false;
}else{
$load_ordering = true;
}
form_alternate_row('', true);
print format_plugin_row($plugin, $last_plugin, $load_ordering);
$i++;
$j++;
}
print $nav;
}else{
print '<tr><td><em>No Plugins Found</em></td></tr>';
}
html_end_box(false);
form_end();
}
function format_plugin_row($plugin, $last_plugin, $include_ordering) {
global $status_names, $config;
static $first_plugin = true;
$row = plugin_actions($plugin);
$row .= "<td><a href='" . htmlspecialchars($plugin['webpage']) . "' target='_blank'><strong>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", ucfirst($plugin['directory'])) : ucfirst($plugin['directory'])) . '</strong></a>' . (is_dir($config['base_path'] . '/plugins/' . $plugin['directory']) ? '':' (<span class="txtErrorText">ERROR: Directory Missing</span>)') . '</td>';
if ($include_ordering) {
$row .= "<td class='nowrap'>";
if (!$first_plugin) {
$row .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=moveup&id=' . $plugin['directory']) . "' title='Order Before Prevous Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/move_up.gif'></a>";
}else{
$row .= "<a href='#' title='Can NOT Reduce Load Order' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/view_none.gif'></a>";
}
if (!$last_plugin) {
$row .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=movedown&id=' . $plugin['directory']) . "' title='Order After Next Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/move_down.gif'></a>";
}else{
$row .= "<a href='#' title='Can Increase Load Order' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/view_none.gif'></a>";
}
$row .= "</td>\n";
}else{
$row .= "<td></td>\n";
}
$row .= "<td class='nowrap'>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $plugin['name']) : $plugin['name']) . "</td>\n";
$row .= '<td>' . $plugin['version'] . "</td>\n";
$row .= "<td class='nowrap'>" . $status_names[$plugin['status']] . "</td>\n";
$row .= "<td class='nowrap'>" . $plugin['author'] . "</td>\n";
$row .= "</tr>\n";
if ($include_ordering) {
$first_plugin = false;
}
return $row;
}
function plugin_actions($plugin) {
global $config;
$link = '<td>';
switch ($plugin['status']) {
case '-2': // Old PA Not Installed
$link .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=installold&id=' . $plugin['directory']) . "' title='Install Old Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/cog_add.png'></a>";
$link .= "<img align='absmiddle' src='" . $config['url_path'] . "images/view_none.gif'>";
break;
case '-1': // Old PA Currently Active
$oldplugins = read_config_option('oldplugins');
if (strlen(trim($oldplugins))) {
$oldplugins = explode(',', $oldplugins);
}else{
$oldplugins = array();
}
if (in_array($plugin['directory'], $oldplugins)) {
$link .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=uninstallold&id=' . $plugin['directory']) . "' title='Uninstall Old Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/cog_delete.png'></a>";
} else {
$link .= "<a href='#' title='Please Uninstall from config.php' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/cog_add.png'></a>";
}
$link .= "<img align='absmiddle' src='" . $config['url_path'] . "images/view_none.gif'>";
break;
case '0': // Not Installed
$link .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=install&id=' . $plugin['directory']) . "' title='Install Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/cog_add.png'></a>";
$link .= "<img align='absmiddle' src='" . $config['url_path'] . "images/view_none.gif'>";
break;
case '1': // Currently Active
$link .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=uninstall&id=' . $plugin['directory']) . "' title='Uninstall Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/cog_delete.png'></a>";
$link .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=disable&id=' . $plugin['directory']) . "' title='Disable Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/stop.png'></a>";
break;
case '2': // Configuration issues
$link .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=uninstall&id=' . $plugin['directory']) . "' title='Uninstall Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/cog_delete.png'></a>";
break;
case '4': // Installed but not active
$link .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=uninstall&id=' . $plugin['directory']) . "' title='Uninstall Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/cog_delete.png'></a>";
$link .= "<a href='" . htmlspecialchars($config['url_path'] . 'plugins.php?mode=enable&id=' . $plugin['directory']) . "' title='Enable Plugin' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/accept.png'></a>";
break;
default: // Old PIA
$link .= "<a href='#' title='Please Install/Uninstall from config.php' class='linkEditMain'><img align='absmiddle' src='" . $config['url_path'] . "images/cog_add.png'></a>";
$link .= "<a href='#' title='Enabling from the UI is not supported' class='linkEditMain'><img align='absmiddle' src='images/cog_error.png'></a>";
break;
}
$link .= '</td>';
return $link;
}