Completed
Branch develop (9f3f84)
by Peter
01:57
created
includes/ddns.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -41,18 +41,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.