This repository was archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontrol-panel.php
More file actions
46 lines (41 loc) · 1.41 KB
/
control-panel.php
File metadata and controls
46 lines (41 loc) · 1.41 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
<?php
require_once 'common.inc.php';
use smtech\CanvasHack\CanvasHack;
use smtech\CanvasHack\CanvasHack_Exception;
use Battis\BootstrapSmarty\NotificationMessage;
if (isset($_REQUEST['hack'])) {
while (list($id, $setting) = each($_REQUEST['hack'])) {
try {
$hack = CanvasHack::getCanvasHackById($toolbox->getMySQL(), $id);
if ($setting === 'enable') {
$hack->enable();
} else {
$hack->disable();
}
} catch (CanvasHack_Exception $e) {
$smarty->addMessage('Exception ' . $e->getCode(), $e->getMessage(), NotificationMessage::ERROR);
}
}
}
$hacksContents = scandir(realpath(__DIR__ . '/hacks'), SCANDIR_SORT_ASCENDING);
$hacks = array();
foreach ($hacksContents as $item) {
if (is_dir($path = realpath(__DIR__ . "/hacks/$item")) && file_exists($manifest = "$path/manifest.xml")) {
try {
$hacks[$item] = new CanvasHack($toolbox->getMySQL(), $path);
} catch (CanvasHack_Exception $e) {
$smarty->addMessage(
'CanvasHack Manifest Error [' . $e->getCode() . ']',
$e->getMessage(),
NotificationMessage::ERROR
);
}
}
}
$smarty->assign([
'appURL' => $toolbox->config('APP_URL'),
'hacks' => $hacks,
'name' => 'CanvasHack',
'category' => 'Control Panel'
]);
$smarty->display('control-panel.tpl');