summaryrefslogtreecommitdiffstats
path: root/modules-available/usblockoff/page.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/usblockoff/page.inc.php')
-rw-r--r--modules-available/usblockoff/page.inc.php78
1 files changed, 51 insertions, 27 deletions
diff --git a/modules-available/usblockoff/page.inc.php b/modules-available/usblockoff/page.inc.php
index e2effad4..efb85fb1 100644
--- a/modules-available/usblockoff/page.inc.php
+++ b/modules-available/usblockoff/page.inc.php
@@ -2,12 +2,15 @@
$glob3 = 'globale Variable 3';
$name = 'testname';
$logedIn = true;
-class Page_usblockoff extends Page {
+
+class Page_usblockoff extends Page
+{
/**
* Called before any page rendering happens - early hook to check parameters etc.
*/
- protected function doPreprocess() {
+ protected function doPreprocess()
+ {
User::load();
if (!User::isLoggedIn()) {
@@ -31,12 +34,14 @@ class Page_usblockoff extends Page {
/**
* Menu etc. has already been generated, now it's time to generate page content.
*/
- protected function doRender() {
+ protected function doRender()
+ {
$this->loadConfigChooser();
}
- protected function loadConfigChooser() {
+ protected function loadConfigChooser()
+ {
$dbquery = Database::simpleQuery("SELECT configid, configname FROM `usb_configs`");
$configs = array();
while ($dbentry = $dbquery->fetch(PDO::FETCH_ASSOC)) {
@@ -45,10 +50,11 @@ class Page_usblockoff extends Page {
$configs[] = $config;
}
- Render::addTemplate('usb-choose-config', array( 'config_list' => array_values($configs)));
+ Render::addTemplate('usb-choose-config', array('config_list' => array_values($configs)));
}
- protected function deleteConfig() {
+ protected function deleteConfig()
+ {
$configID = Request::post('id', 0, 'int');
if ($configID != 0) {
@@ -58,7 +64,8 @@ class Page_usblockoff extends Page {
Util::redirect('?do=usblockoff');
}
- protected function updateConfig() {
+ protected function updateConfig()
+ {
// Add new settings in usbguard-daemon.conf here:
$result['RuleFile'] = Request::post('RuleFile', '', 'string');
$result['ImplicitPolicyTarget'] = Request::post('ImplicitPolicyTarget', '', 'string');
@@ -96,18 +103,23 @@ class Page_usblockoff extends Page {
} else {
$splitstr = explode('=', $line);
- $splitstr[1] = $result[$splitstr[0]];
- $newDaemonConf[] = implode('=', $splitstr)."\r\n";
+ $splitstr[1] = $result[$splitstr[0]];
+ $newDaemonConf[] = implode('=', $splitstr) . "\r\n";
}
}
// INSERT IN DB
if ($id == '0') {
$dbquery = Database::exec("INSERT INTO `usb_configs` (configname, rulesconfig, daemonconfig) VALUES (:configname, :rulesconfig, :daemonconfig)",
- array('configname' => $configname, 'rulesconfig' => $result['rules'], 'daemonconfig' => implode($newDaemonConf)));
+ array('configname' => $configname,
+ 'rulesconfig' => $result['rules'],
+ 'daemonconfig' => implode($newDaemonConf)));
} else {
$dbquery = Database::exec("UPDATE `usb_configs` SET configname=:configname, rulesconfig=:rulesconfig, daemonconfig=:daemonconfig WHERE configid=:configid",
- array('configid' => $id,'configname' => $configname, 'rulesconfig' => $result['rules'], 'daemonconfig' => implode($newDaemonConf)));
+ array('configid' => $id,
+ 'configname' => $configname,
+ 'rulesconfig' => $result['rules'],
+ 'daemonconfig' => implode($newDaemonConf)));
}
}
@@ -129,12 +141,13 @@ class Page_usblockoff extends Page {
}
}
- private function ajaxConfig($id) {
+ private function ajaxConfig($id)
+ {
$form = array();
$rulesConf;
- if($id == 0) {
+ if ($id == 0) {
$currentdir = getcwd();
$rulesConf = file_get_contents($currentdir . '/modules/usblockoff/inc/default-configs/rules.conf');
@@ -172,14 +185,15 @@ class Page_usblockoff extends Page {
));
}
- private function ajaxDeviceList() {
+ private function ajaxDeviceList()
+ {
$usbdevices = array();
$dbquery = Database::simpleQuery("SELECT * FROM `usb_devices`");
while ($entry = $dbquery->fetch(PDO::FETCH_ASSOC)) {
$locationquery = Database::queryFirst("SELECT l.locationname AS 'name', m.clientip AS 'ip' FROM machine AS m JOIN location AS l ON l.locationid=m.locationid
- WHERE m.machineuuid=:machineuuid", array( 'machineuuid' => $entry['machineuuid']));
+ WHERE m.machineuuid=:machineuuid", array('machineuuid' => $entry['machineuuid']));
$device['uid'] = $entry['uid'];
$device['id'] = $entry['id'];
@@ -202,28 +216,38 @@ class Page_usblockoff extends Page {
$settings = array();
$setting = array();
$setting['title'] = "Action";
- $setting['select_list'] = array(array(
+ $setting['select_list'] = array(array(
'option' => 'allow',
'active' => true,
- ), array(
- 'option' => 'block',
- 'active' => false,
- ), array(
- 'option' => 'reject',
- 'active' => false,
- ));
+ ),
+ array(
+ 'option' => 'block',
+ 'active' => false,
+ ),
+ array(
+ 'option' => 'reject',
+ 'active' => false,
+ ));
$setting['helptext'] = array('helptext' => Dictionary::translateFile('rule', 'abr_helptext'));
$setting['property'] = 'action';
$setting['settingHtml'] = Render::parse('server-prop-dropdown', (array)$setting);
$settings[] = $setting;
- $ruleValues = array('id' => true, 'serial' => true, 'name' => true, 'hash' => false, 'parent-hash' => false, 'via-port' => false, 'with-interface' => false, 'interface-policy' => false);
+ $ruleValues = array('id' => true,
+ 'serial' => true,
+ 'name' => true,
+ 'hash' => false,
+ 'parent-hash' => false,
+ 'via-port' => false,
+ 'with-interface' => false,
+ 'interface-policy' => false);
foreach ($ruleValues as $key => $value) {
$settings[] = array(
'settingHtml' => Render::parse('server-prop-bool', array('title' => Dictionary::translateFile('rule', $key),
- 'helptext' => array('helptext' => Dictionary::translateFile('rule', $key . "_helptext")),
- 'property' => $key, 'currentvalue' => $value)),
- );
+ 'helptext' => array('helptext' => Dictionary::translateFile('rule', $key . "_helptext")),
+ 'property' => $key,
+ 'currentvalue' => $value)),
+ );
}
echo Render::parse('usb-device-list', array(