Commit | Line | Data |
---|---|---|
324305fd S |
1 | <?php |
2 | /** | |
3 | * @author Jan Altensen (Stricted) | |
4 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
5 | * @copyright 2015 Jan Altensen (Stricted) | |
6 | */ | |
7 | trait Firewall { | |
8 | /** | |
9 | * get all Portforwarding Entrys | |
10 | * | |
11 | * @return array | |
12 | */ | |
13 | public function getPortforwardingEntrys () { | |
14 | $data = $this->getData('Portforwarding'); | |
15 | $data = $this->getValues($data); | |
16 | ||
17 | //print_r($data); | |
18 | ||
19 | if (isset($data['addportuw'])) { | |
20 | return $data['addportuw']; | |
21 | } | |
22 | else { | |
23 | return array(); | |
24 | } | |
25 | } | |
26 | ||
27 | /** | |
28 | * delete Portforwarding Entry | |
29 | * | |
30 | * @param integer $id | |
31 | * | |
32 | * @return array | |
33 | */ | |
34 | public function deletePortforwardingEntry ($id) { | |
35 | $this->checkLogin(); | |
36 | ||
37 | $path = 'data/Portforwarding.json'; | |
38 | $fields = array('csrf_token' => $this->token, | |
39 | 'id_portforward' => $id, | |
40 | 'deleteEntry' => 'delete' | |
41 | ); | |
42 | ||
43 | $data = $this->sentRequest($path, $fields, true); | |
44 | $data = $this->getValues($data['body']); | |
45 | ||
46 | if ($data['status'] == 'ok') { | |
47 | return $data; | |
48 | } | |
49 | else { | |
50 | throw new RouterException('can not delete Phone Book Entry'); | |
51 | } | |
52 | } | |
53 | ||
54 | /** | |
55 | * add Portforwarding Entry | |
56 | * | |
57 | * @param string $name | |
58 | * @param integer $device | |
59 | */ | |
60 | public function addPortforwardingEntry ($name, $device) { | |
61 | // TODO: find a way to make this possible | |
62 | /* fields: | |
63 | * | |
64 | * portuw_name | |
65 | * portuw_device | |
66 | * optvar_portuw_template = -1 | |
67 | * tcp_public_from | |
68 | * tcp_public_to | |
69 | * tcp_private_dest | |
70 | * tcp_private_to | |
71 | * portuwtcp_id = -1 | |
72 | * | |
73 | * udp_public_from | |
74 | * udp_public_to | |
75 | * udp_private_dest | |
76 | * udp_private_to | |
77 | * portuwudp_id = -1 | |
78 | */ | |
87492136 S |
79 | /* |
80 | var inputs = $("input[name^='tcp_public_'], input[name^='tcp_private_'], input[name^='udp_public_'], input[name^='udp_private_']"); | |
81 | var updateToField = function() { | |
82 | var field = $(this); | |
83 | var prefix = field.is("[name^='tcp_']") ? "tcp" : "udp"; | |
84 | var cont = field.closest("div[id^='template_add']"); | |
85 | var pv = parseInt(cont.find("input[name^='"+prefix+"_public_from']").val()); | |
86 | var pt = parseInt(cont.find("input[name^='"+prefix+"_public_to']").val()); | |
87 | var pp = parseInt(cont.find("input[name^='"+prefix+"_private_dest']").val()); | |
88 | var result = ""; | |
89 | if (!isNaN(pv) && !isNaN(pt) && !isNaN(pp)) { | |
90 | if (pv <= pt) { | |
91 | result = pp + pt - pv; | |
92 | } | |
93 | } | |
94 | cont.find("input[name^='"+prefix+"_private_to']").val(result); | |
95 | }; | |
96 | */ | |
324305fd S |
97 | } |
98 | ||
99 | /** | |
100 | * edit Portforwarding Entry | |
101 | * | |
102 | * @param integer $id | |
103 | * @param string $name | |
104 | * @param integer $device | |
105 | */ | |
106 | public function editPortforwardingEntry ($id, $name, $device) { | |
107 | // TODO: find a way to make this possible | |
108 | } | |
109 | } |