forked from Xkeeper0/jul
-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin-extensions.php
146 lines (128 loc) · 4.65 KB
/
admin-extensions.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
<?php
if (isset($_GET['extfile'])) {
require "admin-settings.php";
die;
}
require "lib/common.php";
require "lib/extension_mgmt.php";
admincheck();
if (isset($_POST['action'])) {
// Reject missing or bad extension file
$_POST['extfile'] = filter_string($_POST['extfile']);
if (!ext_valid($_POST['extfile'])) {
errorpage("Could not complete the requested action for the extenson \"{$_POST['extfile']}\".<br><br>This is not a valid extension.");
}
if (confirmed($msgkey = 'xtman')) {
$redirtext = "the extension management";
switch ($_POST['action']) {
case "disable":
$res = ext_disable($_POST['extfile'], false);
errorpage("Extension '{$_POST['extfile']}' disabled.".($res > 1 ? "<br/>Other ".($res-1)." extensions were disabled due to dependencies." : ""), "admin-extensions.php", $redirtext);
case "enable":
if (($res = ext_enable($_POST['extfile'], false)) !== -1)
$message = "The extension '{$_POST['extfile']}' has been enabled.";
else
$message = "Failed to enable the extension '{$_POST['extfile']}'.<br>Chances are, the required dependencies are missing.";
errorpage($message, "admin-extensions.php", $redirtext);
/*case "uninstall":
if (NO_UNINSTALL)
errorpage("Uninstall extensions is disabled in this version.");
$res = $_POST['extfile']::Uninstall();
errorpage("Extension '{$_POST['extfile']}' removed.".($res > 1 ? "<br/>Other ".($res-1)." extensions were disabled due to dependencies." : ""), "admin-extensions.php", $redirtext);
*/
}
}
// the wonders of using the label as key
$title = "Warning";
$message = "Are you sure you want to {$_POST['action']} the extension '{$_POST['extfile']}'?".
"<input type='hidden' name='action' value=\"".htmlspecialchars($_POST['action'])."\">".
"<input type='hidden' name='extfile' value=\"".htmlspecialchars($_POST['extfile'])."\">";
$form_link = $scriptname;
$buttons = array(
[BTN_SUBMIT, "Yes"],
[BTN_URL, "No", $scriptname]
);
confirm_message($msgkey, $message, $title, $form_link, $buttons);
}
pageheader("Extensions");
print adminlinkbar();
$links = array(
["Optional features", null],
);
$barlinks = dobreadcrumbs($links);
// Get all extensions installed, including disabled ones
$extensions = ext_get_all_metadata();
?>
<style>
.installCtrl {
float: right;
text-align: right;
padding-right: 10px; /* 10px 10px 0px; */
}
.settingsCtrl {
padding-top: 10px;
}
</style>
<?= $barlinks ?>
<?php
foreach ($extensions as $ext) {
?>
<form method="POST" action="admin-extensions.php">
<input type="hidden" name="extfile" value="<?= $ext['file'] ?>">
<table class="table">
<thead>
<tr>
<td class="tdbgh b" colspan="2">
<?= $ext['name'].($ext['enabled'] ? "" : "<i>(disabled)</i>") ?> v<?=$ext['version']?>
</td>
</tr>
</thead>
<tbody>
<tr>
<td class="tdbg1 vatop" style="width: 1px">
<?= ($ext['image'] ? "<img src=\"extensions/{$ext['file']}.abx/{$ext['image']}\">" : "") ?>
</td>
<td class="tdbg2">
<?php /*
<span class="installCtrl">
<input type="submit" name="action" value="Uninstall" disabled style='background: #333; color: #aaa'>
<div class="settingsCtrl">
<input type="submit" name="settings" value="Settings">
</div>
</span>
<span class="installCtrl">
<?=
$ext['enabled']
? '<button type="submit" name="action" value="disable">Enable</button>'
: '<button type="submit" name="action" value="enable">Disable</button>'
?>
</span>*/?>
<span class="installCtrl">
<?=
$ext['enabled']
? '<button type="submit" name="action" value="disable">Disable</button>'
: '<button type="submit" name="action" value="enable">Enable</button>'
?>
<div class="settingsCtrl">
<?php if (filter_bool($ext['configpage'])) { ?>
<a href="<?=$ext['file']?>/config" class="button">Configure</a>
<?php }
if (!filter_bool($ext['noconfig'])) { ?>
<a href="?extfile=<?=$ext['file']?>" class="button">Settings</a>
<?php } ?>
</div>
</span>
<?= $ext['description'] ?><br>
<br>
<span class="fonts">
By: <?= $ext['author'] . ($ext['enabled'] ? "<br/>Enabled on: ".(isset($ext['enableTime']) ? $ext['enableDate'] : "<i>Start of the board</i>") : "") . ($ext['installed'] ? "<br/>Installed on: {$ext['installDate']}" : "") ?><br/>
Version: <?=$ext['version']?> (<?=$ext['date']?>)
</span>
</td>
</tr>
</tbody>
</table>
</form>
<?php
}
pagefooter();