add NotImplementedException and update version to 1.0.5
[GitHub/Stricted/speedport-hybrid-php-api.git] / lib / trait / Firewall.class.php
CommitLineData
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 */
7trait 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
324305fd
S
17 if (isset($data['addportuw'])) {
18 return $data['addportuw'];
19 }
20 else {
21 return array();
22 }
23 }
24
25 /**
26 * delete Portforwarding Entry
27 *
28 * @param integer $id
29 *
30 * @return array
31 */
32 public function deletePortforwardingEntry ($id) {
33 $this->checkLogin();
34
35 $path = 'data/Portforwarding.json';
36 $fields = array('csrf_token' => $this->token,
37 'id_portforward' => $id,
38 'deleteEntry' => 'delete'
39 );
40
41 $data = $this->sentRequest($path, $fields, true);
42 $data = $this->getValues($data['body']);
43
44 if ($data['status'] == 'ok') {
45 return $data;
46 }
47 else {
48 throw new RouterException('can not delete Phone Book Entry');
49 }
50 }
51
52 /**
53 * add Portforwarding Entry
54 *
55 * @param string $name
56 * @param integer $device
57 */
58 public function addPortforwardingEntry ($name, $device) {
1a5b0fe3
S
59 throw new NotImplementedException();
60
324305fd
S
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) {
1a5b0fe3 107 throw new NotImplementedException();
324305fd
S
108 // TODO: find a way to make this possible
109 }
110}