-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathplugins.php
More file actions
139 lines (118 loc) · 5.14 KB
/
plugins.php
File metadata and controls
139 lines (118 loc) · 5.14 KB
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
<?php
require('checkallowed.php'); // Check logged-in
?>
<div class="page_title">
<div class="page_title_icon"><img src="../images/icons/medium/plugins.png" border="0" /></div>
<div class="page_title_text"><?php echo $lang['plugins']; ?></div>
</div>
<div class="infobox" style="display:none;"></div>
<?php $Plugins->do_action('plugins_top'); // Plugins ?>
<div class="box">
<div class="box_title" id="box_servers_title"><?php echo $lang['plugins']; ?></div>
<div class="box_content" id="box_servers_content">
<table border="0" cellpadding="0" cellspacing="0" align="center" width="800" class="box_table" id="plugins_table" style="text-align:left;">
<tr>
<td width="25"> </td>
<td width="180"><b><?php echo $lang['name']; ?></b></td>
<td width="200"><b><?php echo $lang['desc']; ?></b></td>
<td width="100"><b><?php echo $lang['status']; ?></b></td>
</tr>
<?php
$Plugins->do_action('plugins_table'); // Plugins
// List plugins
$result_def = @mysql_query("SELECT
id,
active,
description,
intname,
name
FROM plugins
ORDER BY
active DESC,
name ASC") or die('Failed to query for plugins: '.mysql_error());
// Array of known plugins
$known = array();
while($row_def = mysql_fetch_array($result_def))
{
$plg_id = $row_def['id'];
$plg_active = $row_def['active'];
$plg_descr = htmlspecialchars($row_def['description']);
$plg_intname = htmlspecialchars($row_def['intname']);
$plg_name = htmlspecialchars($row_def['name']);
$known[] = $plg_intname; // Add to array of known plugins
// Active
if($plg_active)
{
$plg_active = ' selected';
$plg_inactive = '';
}
else
{
$plg_active = '';
$plg_inactive = ' selected';
}
// Icons
if(file_exists('../plugins/'.$plg_intname.'/icon.png')) $plugin_img = '<img src="../plugins/'.$plg_intname.'/icon.png" width="20" height="20" border="0" />';
else $plugin_img = ' ';
echo '<tr id="plugin_' . $plg_id . '">
<td>'.$plugin_img.'</td>
<td>' . $plg_name . '</td>
<td style="font-size:9pt;">' . $plg_descr . '</td>
<td>
<select id="plg_'.$plg_id.'_status" class="dropdown" onChange="javascript:plugin_update_active('.$plg_id.');">
<option value="active"'.$plg_active.'>'.$lang['active'].'</option>
<option value="inactive"'.$plg_inactive.'>'.$lang['inactive'].'</option>
<option value="delete">'.$lang['delete'].'</option>
</select>';
echo '</td>
</tr>';
}
########################################################################
// Plugins in directory / Waiting plugins (plugins that are not yet installed)
if($handle = opendir(DOCROOT.'/plugins'))
{
while (false !== ($entry = readdir($handle)))
{
// No . dirs, no plugins previously listed above
if(!preg_match('/^\./', $entry) && !in_array($entry, $known) && !preg_match('/\.php$/', $entry))
{
// Icon
if(file_exists('../plugins/'.$entry.'/icon.png')) $plugin_img = '<img src="../plugins/'.$entry.'/icon.png" width="20" height="20" border="0" />';
else $plugin_img = ' ';
if(file_exists(DOCROOT.'/plugins/'.$entry.'/plugin.json.txt'))
{
// Read JSON file
$fh = fopen(DOCROOT.'/plugins/'.$entry.'/plugin.json.txt', 'r') or die('Unable to open JSON plugin file ('.$entry.')');
$theData = fread($fh, 8096);
fclose($fh);
// Get plugin JSON info
$json_info = json_decode($theData, true);
$newplg_name = $json_info['name'];
$newplg_intname = htmlspecialchars($json_info['intname']);
$newplg_desc = htmlspecialchars($json_info['description']);
#echo '<pre>';
#var_dump($json_info);
#echo '</pre>';
}
else
{
$newplg_name = $entry;
$newplg_intname = $entry;
$newplg_desc = $lang['unknown'];
}
// Show available plugin info
echo '<tr>
<td>'.$plugin_img.'</td>
<td><b>' . $newplg_name . '</b></td>
<td style="font-size:9pt;"><b>' . $newplg_desc . '</b></td>
<td>'.$lang['not_installed'].' (<span class="links" onClick="javascript:plugin_install(\'' . $newplg_intname . '\');">'.$lang['install'].'</span>)</td>
</tr>';
}
}
closedir($handle);
}
?>
</table>
</div>
</div>
<?php $Plugins->do_action('plugins_bottom'); // Plugins ?>