forked from tuxudo/firewall
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirewall_controller.php
executable file
·112 lines (104 loc) · 2.82 KB
/
firewall_controller.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
<?php
/**
* firewall module class
*
* @package munkireport
* @author tuxudo
**/
class Firewall_controller extends Module_controller
{
/*** Protect methods with auth! ****/
function __construct()
{
// Store module path
$this->module_path = dirname(__FILE__);
}
/**
* Default method
* @author tuxudo
*
**/
function index()
{
echo "You've loaded the firewall module!";
}
/**
* Firewall state widget
*
* @return void
* @author tuxudo
**/
public function get_global_state()
{
jsonView(
Firewall_model::selectRaw("COUNT(CASE WHEN `globalstate` = '1' THEN 1 END) AS 'on'")
->selectRaw("COUNT(CASE WHEN `globalstate` = '0' THEN 1 END) AS 'off'")
->selectRaw("COUNT(CASE WHEN `globalstate` = '2' THEN 1 END) AS 'limited'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Firewall allowsignedenabled widget
*
* @return void
* @author tuxudo
**/
public function get_allowsignedenabled()
{
jsonView(
Firewall_model::selectRaw("COUNT(CASE WHEN `allowsignedenabled` = '1' THEN 1 END) AS 'on'")
->selectRaw("COUNT(CASE WHEN `allowsignedenabled` = '0' THEN 1 END) AS 'off'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Firewall stealthenabled widget
*
* @return void
* @author tuxudo
**/
public function get_stealthenabled()
{
jsonView(
Firewall_model::selectRaw("COUNT(CASE WHEN `stealthenabled` = '1' THEN 1 END) AS 'on'")
->selectRaw("COUNT(CASE WHEN `stealthenabled` = '0' THEN 1 END) AS 'off'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Firewall allowdownloadsignedenabled widget
*
* @return void
* @author tuxudo
**/
public function get_allowdownloadsignedenabled()
{
jsonView(
Firewall_model::selectRaw("COUNT(CASE WHEN `allowdownloadsignedenabled` = '1' THEN 1 END) AS 'on'")
->selectRaw("COUNT(CASE WHEN `allowdownloadsignedenabled` = '0' THEN 1 END) AS 'off'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Retrieve data in json format
*
**/
public function get_firewall_data($serial_number)
{
jsonView(
Firewall_model::selectRaw('globalstate, stealthenabled, allowsignedenabled, allowdownloadsignedenabled, loggingenabled, loggingoption, firewallunload, services, applications')
->where('firewall.serial_number', $serial_number)
->filter()
->get()
->toArray()
);
}
} // End class Firewall_controller