@@ -169,6 +169,9 @@ |
||
169 | 169 | return; |
170 | 170 | } |
171 | 171 | |
172 | + /** |
|
173 | + * @param string $type |
|
174 | + */ |
|
172 | 175 | protected function inwxSetNameserverInfo($type = null) |
173 | 176 | { |
174 | 177 | $object = "nameserver"; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | protected function setIniFileDomain($apidomain = null) |
51 | 51 | { |
52 | 52 | preg_match("/(?!.{253})((?!-)[A-Za-z0-9-]{1,63}(?<!-)\.){1,126}+[A-Za-z]{2,6}/", $apidomain, $domainReturn); |
53 | - $domainReturn[0] = str_replace('.', '-', $domainReturn[0]); |
|
53 | + $domainReturn[0] = str_replace('.', '-', $domainReturn[0]); |
|
54 | 54 | |
55 | 55 | $this->iniFileDomain = $domainReturn[0] . '.ini'; |
56 | 56 | |
@@ -152,42 +152,42 @@ discard block |
||
152 | 152 | exit('something went wrong 6'); |
153 | 153 | } |
154 | 154 | |
155 | - foreach($result["resData"]["record"] as $value) |
|
156 | - { |
|
157 | - if($value['type'] == "A") |
|
158 | - { |
|
159 | - $this->IP4['id'] = $value['id']; |
|
160 | - $this->IP4['oldip'] = $value['content']; |
|
161 | - } |
|
162 | - if($value['type'] == "AAAA") |
|
163 | - { |
|
164 | - $this->IP6['id'] = $value['id']; |
|
165 | - $this->IP6['oldip'] = $value['content']; |
|
166 | - } |
|
167 | - } |
|
155 | + foreach($result["resData"]["record"] as $value) |
|
156 | + { |
|
157 | + if($value['type'] == "A") |
|
158 | + { |
|
159 | + $this->IP4['id'] = $value['id']; |
|
160 | + $this->IP4['oldip'] = $value['content']; |
|
161 | + } |
|
162 | + if($value['type'] == "AAAA") |
|
163 | + { |
|
164 | + $this->IP6['id'] = $value['id']; |
|
165 | + $this->IP6['oldip'] = $value['content']; |
|
166 | + } |
|
167 | + } |
|
168 | 168 | |
169 | 169 | return; |
170 | 170 | } |
171 | 171 | |
172 | - protected function inwxSetNameserverInfo($type = null) |
|
172 | + protected function inwxSetNameserverInfo($type = null) |
|
173 | 173 | { |
174 | 174 | $object = "nameserver"; |
175 | 175 | $methode = "updateRecord"; |
176 | 176 | |
177 | 177 | $params = array(); |
178 | 178 | |
179 | - if($type == 'ipv4') |
|
180 | - { |
|
181 | - $params['id'] = $this->IP4['id']; |
|
182 | - $params['content'] = $this->IP4['newip']; |
|
183 | - } |
|
184 | - elseif($type == 'ipv6') |
|
185 | - { |
|
186 | - $params['id'] = $this->IP6['id']; |
|
187 | - $params['content'] = $this->IP6['newip']; |
|
188 | - } |
|
189 | - else |
|
190 | - exit('something went wrong 9'); |
|
179 | + if($type == 'ipv4') |
|
180 | + { |
|
181 | + $params['id'] = $this->IP4['id']; |
|
182 | + $params['content'] = $this->IP4['newip']; |
|
183 | + } |
|
184 | + elseif($type == 'ipv6') |
|
185 | + { |
|
186 | + $params['id'] = $this->IP6['id']; |
|
187 | + $params['content'] = $this->IP6['newip']; |
|
188 | + } |
|
189 | + else |
|
190 | + exit('something went wrong 9'); |
|
191 | 191 | |
192 | 192 | $result = $this->domrobot->call($object, $methode, $params); |
193 | 193 | |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | exit('something went wrong 10'); |
201 | 201 | } |
202 | 202 | |
203 | - if(OUTPUT) |
|
204 | - echo('good'); |
|
203 | + if(OUTPUT) |
|
204 | + echo('good'); |
|
205 | 205 | |
206 | 206 | return; |
207 | 207 | } |
@@ -212,17 +212,17 @@ discard block |
||
212 | 212 | |
213 | 213 | $this->inwxGetNameserverInfo(); |
214 | 214 | |
215 | - if(filter_var($ipv4, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) |
|
216 | - { |
|
217 | - $this->IP4['newip'] = $ipv4; |
|
218 | - $this->inwxSetNameserverInfo('ipv4'); |
|
219 | - } |
|
215 | + if(filter_var($ipv4, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) |
|
216 | + { |
|
217 | + $this->IP4['newip'] = $ipv4; |
|
218 | + $this->inwxSetNameserverInfo('ipv4'); |
|
219 | + } |
|
220 | 220 | |
221 | - if(filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) |
|
222 | - { |
|
223 | - $this->IP6['newip'] = $ipv6; |
|
224 | - $this->inwxSetNameserverInfo('ipv6'); |
|
225 | - } |
|
221 | + if(filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) |
|
222 | + { |
|
223 | + $this->IP6['newip'] = $ipv6; |
|
224 | + $this->inwxSetNameserverInfo('ipv6'); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | $this->inwxLogout(); |
228 | 228 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | { |
22 | 22 | $str = htmlspecialchars(trim($str), ENT_QUOTES, 'UTF-8'); |
23 | 23 | |
24 | - if($checkEmpty && empty($str)) |
|
24 | + if ($checkEmpty && empty($str)) |
|
25 | 25 | exit('something went wrong 7'); |
26 | 26 | |
27 | 27 | return $str; |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | protected $iniFileInwx = "inwx.ini"; |
34 | 34 | protected $iniFileDomain = ""; |
35 | 35 | |
36 | - protected $inwx = []; // {apiurl, username, password} |
|
37 | - protected $domain = []; // [inwx] => {domain, subdomain}, [ddns] => {apikey} |
|
38 | - protected $IP4 = []; // {oldip, newip, id} |
|
39 | - protected $IP6 = []; // {oldip, newip, id} |
|
36 | + protected $inwx = []; // {apiurl, username, password} |
|
37 | + protected $domain = []; // [inwx] => {domain, subdomain}, [ddns] => {apikey} |
|
38 | + protected $IP4 = []; // {oldip, newip, id} |
|
39 | + protected $IP6 = []; // {oldip, newip, id} |
|
40 | 40 | |
41 | 41 | protected $domrobot; |
42 | 42 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | protected function readIni() |
61 | 61 | { |
62 | 62 | // check if ini files exists |
63 | - if(!file_exists($this->iniFilePath . $this->iniFileDomain)) |
|
63 | + if (!file_exists($this->iniFilePath . $this->iniFileDomain)) |
|
64 | 64 | exit('something went wrong 8'); |
65 | - if(!file_exists($this->iniFilePath . $this->iniFileInwx)) |
|
65 | + if (!file_exists($this->iniFilePath . $this->iniFileInwx)) |
|
66 | 66 | exit('something went wrong 1'); |
67 | 67 | |
68 | 68 | // read domain.ini |
@@ -76,16 +76,16 @@ discard block |
||
76 | 76 | //read inwx.ini |
77 | 77 | $ini = parse_ini_file($this->iniFilePath . $this->iniFileInwx, TRUE); |
78 | 78 | |
79 | - $this->inwx['apiurl'] = precheck($ini['apiurl'], true); |
|
80 | - $this->inwx['username'] = precheck($ini['username'], true); |
|
81 | - $this->inwx['password'] = precheck($ini['password'], true); |
|
79 | + $this->inwx['apiurl'] = precheck($ini['apiurl'], true); |
|
80 | + $this->inwx['username'] = precheck($ini['username'], true); |
|
81 | + $this->inwx['password'] = precheck($ini['password'], true); |
|
82 | 82 | |
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | 86 | protected function checkAccess($apikey = null) |
87 | 87 | { |
88 | - if($apikey == null || $this->domain['ddns']['apikey'] !== $apikey) |
|
88 | + if ($apikey == null || $this->domain['ddns']['apikey'] !== $apikey) |
|
89 | 89 | exit('something went wrong 3'); |
90 | 90 | |
91 | 91 | return; |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | // INWX Login |
102 | 102 | $result = $this->domrobot->login($this->inwx['username'], $this->inwx['password']); |
103 | 103 | |
104 | - if(DEBUG) |
|
104 | + if (DEBUG) |
|
105 | 105 | print_r($result); |
106 | 106 | |
107 | 107 | // check result |
108 | 108 | if ($result['code'] != 1000) |
109 | 109 | { |
110 | - if(OUTPUT) |
|
110 | + if (OUTPUT) |
|
111 | 111 | exit('badauth'); |
112 | 112 | |
113 | 113 | exit('something went wrong 4'); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $result = $this->domrobot->logout(); |
122 | 122 | |
123 | - if(DEBUG) |
|
123 | + if (DEBUG) |
|
124 | 124 | print_r($result); |
125 | 125 | |
126 | 126 | // check result |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | $result = $this->domrobot->call($object, $methode, $params); |
145 | 145 | |
146 | - if(DEBUG) |
|
146 | + if (DEBUG) |
|
147 | 147 | print_r($result); |
148 | 148 | |
149 | 149 | // check result |
@@ -152,14 +152,14 @@ discard block |
||
152 | 152 | exit('something went wrong 6'); |
153 | 153 | } |
154 | 154 | |
155 | - foreach($result["resData"]["record"] as $value) |
|
155 | + foreach ($result["resData"]["record"] as $value) |
|
156 | 156 | { |
157 | - if($value['type'] == "A") |
|
157 | + if ($value['type'] == "A") |
|
158 | 158 | { |
159 | 159 | $this->IP4['id'] = $value['id']; |
160 | 160 | $this->IP4['oldip'] = $value['content']; |
161 | 161 | } |
162 | - if($value['type'] == "AAAA") |
|
162 | + if ($value['type'] == "AAAA") |
|
163 | 163 | { |
164 | 164 | $this->IP6['id'] = $value['id']; |
165 | 165 | $this->IP6['oldip'] = $value['content']; |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | |
177 | 177 | $params = array(); |
178 | 178 | |
179 | - if($type == 'ipv4') |
|
179 | + if ($type == 'ipv4') |
|
180 | 180 | { |
181 | 181 | $params['id'] = $this->IP4['id']; |
182 | 182 | $params['content'] = $this->IP4['newip']; |
183 | 183 | } |
184 | - elseif($type == 'ipv6') |
|
184 | + elseif ($type == 'ipv6') |
|
185 | 185 | { |
186 | 186 | $params['id'] = $this->IP6['id']; |
187 | 187 | $params['content'] = $this->IP6['newip']; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | $result = $this->domrobot->call($object, $methode, $params); |
193 | 193 | |
194 | - if(DEBUG) |
|
194 | + if (DEBUG) |
|
195 | 195 | print_r($result); |
196 | 196 | |
197 | 197 | // check result |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | exit('something went wrong 10'); |
201 | 201 | } |
202 | 202 | |
203 | - if(OUTPUT) |
|
203 | + if (OUTPUT) |
|
204 | 204 | echo('good'); |
205 | 205 | |
206 | 206 | return; |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | |
213 | 213 | $this->inwxGetNameserverInfo(); |
214 | 214 | |
215 | - if(filter_var($ipv4, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) |
|
215 | + if (filter_var($ipv4, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) |
|
216 | 216 | { |
217 | 217 | $this->IP4['newip'] = $ipv4; |
218 | 218 | $this->inwxSetNameserverInfo('ipv4'); |
219 | 219 | } |
220 | 220 | |
221 | - if(filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) |
|
221 | + if (filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) |
|
222 | 222 | { |
223 | 223 | $this->IP6['newip'] = $ipv6; |
224 | 224 | $this->inwxSetNameserverInfo('ipv6'); |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | { |
22 | 22 | $str = htmlspecialchars(trim($str), ENT_QUOTES, 'UTF-8'); |
23 | 23 | |
24 | - if($checkEmpty && empty($str)) |
|
25 | - exit('something went wrong 7'); |
|
24 | + if($checkEmpty && empty($str)) { |
|
25 | + exit('something went wrong 7'); |
|
26 | + } |
|
26 | 27 | |
27 | 28 | return $str; |
28 | 29 | } |
@@ -60,10 +61,12 @@ discard block |
||
60 | 61 | protected function readIni() |
61 | 62 | { |
62 | 63 | // check if ini files exists |
63 | - if(!file_exists($this->iniFilePath . $this->iniFileDomain)) |
|
64 | - exit('something went wrong 8'); |
|
65 | - if(!file_exists($this->iniFilePath . $this->iniFileInwx)) |
|
66 | - exit('something went wrong 1'); |
|
64 | + if(!file_exists($this->iniFilePath . $this->iniFileDomain)) { |
|
65 | + exit('something went wrong 8'); |
|
66 | + } |
|
67 | + if(!file_exists($this->iniFilePath . $this->iniFileInwx)) { |
|
68 | + exit('something went wrong 1'); |
|
69 | + } |
|
67 | 70 | |
68 | 71 | // read domain.ini |
69 | 72 | $ini = parse_ini_file($this->iniFilePath . $this->iniFileDomain, TRUE); |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | |
86 | 89 | protected function checkAccess($apikey = null) |
87 | 90 | { |
88 | - if($apikey == null || $this->domain['ddns']['apikey'] !== $apikey) |
|
89 | - exit('something went wrong 3'); |
|
91 | + if($apikey == null || $this->domain['ddns']['apikey'] !== $apikey) { |
|
92 | + exit('something went wrong 3'); |
|
93 | + } |
|
90 | 94 | |
91 | 95 | return; |
92 | 96 | } |
@@ -101,14 +105,16 @@ discard block |
||
101 | 105 | // INWX Login |
102 | 106 | $result = $this->domrobot->login($this->inwx['username'], $this->inwx['password']); |
103 | 107 | |
104 | - if(DEBUG) |
|
105 | - print_r($result); |
|
108 | + if(DEBUG) { |
|
109 | + print_r($result); |
|
110 | + } |
|
106 | 111 | |
107 | 112 | // check result |
108 | 113 | if ($result['code'] != 1000) |
109 | 114 | { |
110 | - if(OUTPUT) |
|
111 | - exit('badauth'); |
|
115 | + if(OUTPUT) { |
|
116 | + exit('badauth'); |
|
117 | + } |
|
112 | 118 | |
113 | 119 | exit('something went wrong 4'); |
114 | 120 | } |
@@ -120,8 +126,9 @@ discard block |
||
120 | 126 | { |
121 | 127 | $result = $this->domrobot->logout(); |
122 | 128 | |
123 | - if(DEBUG) |
|
124 | - print_r($result); |
|
129 | + if(DEBUG) { |
|
130 | + print_r($result); |
|
131 | + } |
|
125 | 132 | |
126 | 133 | // check result |
127 | 134 | if ($result['code'] != 1500) |
@@ -143,8 +150,9 @@ discard block |
||
143 | 150 | |
144 | 151 | $result = $this->domrobot->call($object, $methode, $params); |
145 | 152 | |
146 | - if(DEBUG) |
|
147 | - print_r($result); |
|
153 | + if(DEBUG) { |
|
154 | + print_r($result); |
|
155 | + } |
|
148 | 156 | |
149 | 157 | // check result |
150 | 158 | if ($result['code'] != 1000) |
@@ -180,19 +188,19 @@ discard block |
||
180 | 188 | { |
181 | 189 | $params['id'] = $this->IP4['id']; |
182 | 190 | $params['content'] = $this->IP4['newip']; |
183 | - } |
|
184 | - elseif($type == 'ipv6') |
|
191 | + } elseif($type == 'ipv6') |
|
185 | 192 | { |
186 | 193 | $params['id'] = $this->IP6['id']; |
187 | 194 | $params['content'] = $this->IP6['newip']; |
195 | + } else { |
|
196 | + exit('something went wrong 9'); |
|
188 | 197 | } |
189 | - else |
|
190 | - exit('something went wrong 9'); |
|
191 | 198 | |
192 | 199 | $result = $this->domrobot->call($object, $methode, $params); |
193 | 200 | |
194 | - if(DEBUG) |
|
195 | - print_r($result); |
|
201 | + if(DEBUG) { |
|
202 | + print_r($result); |
|
203 | + } |
|
196 | 204 | |
197 | 205 | // check result |
198 | 206 | if ($result['code'] != 1000) |
@@ -200,8 +208,9 @@ discard block |
||
200 | 208 | exit('something went wrong 10'); |
201 | 209 | } |
202 | 210 | |
203 | - if(OUTPUT) |
|
204 | - echo('good'); |
|
211 | + if(OUTPUT) { |
|
212 | + echo('good'); |
|
213 | + } |
|
205 | 214 | |
206 | 215 | return; |
207 | 216 | } |
@@ -15,10 +15,10 @@ |
||
15 | 15 | protected $iniFilePath = "./conf/"; |
16 | 16 | protected $iniFileInwx = "inwx.ini"; |
17 | 17 | protected $iniFileDomain = ""; |
18 | - protected $inwx = []; // {apiurl, username, password} |
|
19 | - protected $domain = []; // [inwx] => {domain, subdomain}, [ddns] => {apikey} |
|
20 | - protected $IP4 = []; // {oldip, newip, id} |
|
21 | - protected $IP6 = []; // {oldip, newip, id} |
|
18 | + protected $inwx = []; // {apiurl, username, password} |
|
19 | + protected $domain = []; // [inwx] => {domain, subdomain}, [ddns] => {apikey} |
|
20 | + protected $IP4 = []; // {oldip, newip, id} |
|
21 | + protected $IP6 = []; // {oldip, newip, id} |
|
22 | 22 | protected $domrobot; |
23 | 23 | |
24 | 24 | public function __construct($apidomain = null, $apikey = null) { |
@@ -41,18 +41,21 @@ discard block |
||
41 | 41 | protected function precheck($str) { |
42 | 42 | $str = htmlspecialchars(trim($str), ENT_QUOTES, 'UTF-8'); |
43 | 43 | |
44 | - if (empty($str)) |
|
45 | - exit('something went wrong 7'); |
|
44 | + if (empty($str)) { |
|
45 | + exit('something went wrong 7'); |
|
46 | + } |
|
46 | 47 | |
47 | 48 | return $str; |
48 | 49 | } |
49 | 50 | |
50 | 51 | protected function readIni() { |
51 | 52 | // check if ini files exists |
52 | - if (!file_exists($this->iniFilePath . $this->iniFileDomain)) |
|
53 | - exit('something went wrong 8'); |
|
54 | - if (!file_exists($this->iniFilePath . $this->iniFileInwx)) |
|
55 | - exit('something went wrong 1'); |
|
53 | + if (!file_exists($this->iniFilePath . $this->iniFileDomain)) { |
|
54 | + exit('something went wrong 8'); |
|
55 | + } |
|
56 | + if (!file_exists($this->iniFilePath . $this->iniFileInwx)) { |
|
57 | + exit('something went wrong 1'); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | // read domain.ini |
58 | 61 | $ini = parse_ini_file($this->iniFilePath . $this->iniFileDomain, TRUE); |
@@ -73,8 +76,9 @@ discard block |
||
73 | 76 | } |
74 | 77 | |
75 | 78 | protected function checkAccess($apikey = null) { |
76 | - if ($apikey == null || $this->domain['ddns']['apikey'] !== $apikey) |
|
77 | - exit('something went wrong 3'); |
|
79 | + if ($apikey == null || $this->domain['ddns']['apikey'] !== $apikey) { |
|
80 | + exit('something went wrong 3'); |
|
81 | + } |
|
78 | 82 | |
79 | 83 | return; |
80 | 84 | } |
@@ -88,13 +92,15 @@ discard block |
||
88 | 92 | // INWX Login |
89 | 93 | $result = $this->domrobot->login($this->inwx['username'], $this->inwx['password']); |
90 | 94 | |
91 | - if (DEBUG) |
|
92 | - print_r($result); |
|
95 | + if (DEBUG) { |
|
96 | + print_r($result); |
|
97 | + } |
|
93 | 98 | |
94 | 99 | // check result |
95 | 100 | if ($result['code'] != 1000) { |
96 | - if (OUTPUT) |
|
97 | - exit('badauth'); |
|
101 | + if (OUTPUT) { |
|
102 | + exit('badauth'); |
|
103 | + } |
|
98 | 104 | |
99 | 105 | exit('something went wrong 4'); |
100 | 106 | } |
@@ -105,8 +111,9 @@ discard block |
||
105 | 111 | protected function inwxLogout() { |
106 | 112 | $result = $this->domrobot->logout(); |
107 | 113 | |
108 | - if (DEBUG) |
|
109 | - print_r($result); |
|
114 | + if (DEBUG) { |
|
115 | + print_r($result); |
|
116 | + } |
|
110 | 117 | |
111 | 118 | // check result |
112 | 119 | if ($result['code'] != 1500) { |
@@ -126,8 +133,9 @@ discard block |
||
126 | 133 | |
127 | 134 | $result = $this->domrobot->call($object, $methode, $params); |
128 | 135 | |
129 | - if (DEBUG) |
|
130 | - print_r($result); |
|
136 | + if (DEBUG) { |
|
137 | + print_r($result); |
|
138 | + } |
|
131 | 139 | |
132 | 140 | // check result |
133 | 141 | if ($result['code'] != 1000) { |
@@ -160,21 +168,24 @@ discard block |
||
160 | 168 | } elseif ($type == 'ipv6') { |
161 | 169 | $params['id'] = $this->IP6['id']; |
162 | 170 | $params['content'] = $this->IP6['newip']; |
163 | - } else |
|
164 | - exit('something went wrong 9'); |
|
171 | + } else { |
|
172 | + exit('something went wrong 9'); |
|
173 | + } |
|
165 | 174 | |
166 | 175 | $result = $this->domrobot->call($object, $methode, $params); |
167 | 176 | |
168 | - if (DEBUG) |
|
169 | - print_r($result); |
|
177 | + if (DEBUG) { |
|
178 | + print_r($result); |
|
179 | + } |
|
170 | 180 | |
171 | 181 | // check result |
172 | 182 | if ($result['code'] != 1000) { |
173 | 183 | exit('something went wrong 10'); |
174 | 184 | } |
175 | 185 | |
176 | - if (OUTPUT) |
|
177 | - echo('good'); |
|
186 | + if (OUTPUT) { |
|
187 | + echo('good'); |
|
188 | + } |
|
178 | 189 | |
179 | 190 | return; |
180 | 191 | } |