Completed
Push — develop ( 9d5b94...675582 )
by Seth
06:11
created

control-panel.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
require_once('common.inc.php');
4
5
use smtech\CanvasHack\CanvasHack;
6
use smtech\CanvasHack\CanvasHack_Exception;
7
use Battis\BootstrapSmarty\NotificationMessage;
8
9
if (isset($_REQUEST['hack'])) {
10
	while (list($id, $setting) = each($_REQUEST['hack'])) {
11
		try{
12
13
			$hack = CanvasHack::getCanvasHackById($sql, $id);
14
			if ($setting === 'enable') {
15
				$hack->enable();
16
			} else {
17
				$hack->disable();
18
			}
19
		} catch (CanvasHack_Exception $e) {
20
			$smarty->addMessage('Exception ' . $e->getCode(), $e->getMessage(), NotificationMessage::ERROR);
0 ignored issues
show
Deprecated Code introduced by
The constant Battis\BootstrapSmarty\NotificationMessage::ERROR has been deprecated with message: Use `DANGER` instead for consistency with Bootstrap

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
21
		}
22
	}
23
}
24
25
$hacksContents = scandir(realpath(__DIR__ . '/hacks'), SCANDIR_SORT_ASCENDING);
26
$hacks = array();
27
foreach($hacksContents as $item) {
28
	if (is_dir($path = realpath(__DIR__ . "/hacks/$item")) && file_exists($manifest = "$path/manifest.xml")) {
29
		try {
30
			$hacks[$item] = new CanvasHack($sql, $path);
31
		} catch (CanvasHack_Exception $e) {
32
			$smarty->addMessage(
33
				'CanvasHack Manifest Error ['. $e->getCode() . ']',
34
				$e->getMessage(),
35
				NotificationMessage::ERROR
0 ignored issues
show
Deprecated Code introduced by
The constant Battis\BootstrapSmarty\NotificationMessage::ERROR has been deprecated with message: Use `DANGER` instead for consistency with Bootstrap

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
36
			);
37
		}
38
	}
39
}
40
41
$smarty->assign('appURL', $metadata['APP_URL']);
42
$smarty->assign('hacks', $hacks);
43
$smarty->display('control-panel.tpl');
44
45
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
46