Passed
Branch master (ff9d34)
by Mike
09:14
created
lib/request/request.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
     }
351 351
 
352 352
     /**
353
-    * Returns if the AcceptMultipart parameter of the querystring is set
354
-    *
355
-    * @access public
356
-    * @return boolean
357
-    */
353
+     * Returns if the AcceptMultipart parameter of the querystring is set
354
+     *
355
+     * @access public
356
+     * @return boolean
357
+     */
358 358
     static public function GetGETAcceptMultipart() {
359 359
         if (isset(self::$acceptMultipart))
360 360
             return self::$acceptMultipart;
@@ -718,11 +718,11 @@  discard block
 block discarded – undo
718 718
      * @return string
719 719
      */
720 720
     static private function filterIP($input) {
721
-      $in_addr = @inet_pton($input);
722
-      if ($in_addr === false) {
721
+        $in_addr = @inet_pton($input);
722
+        if ($in_addr === false) {
723 723
         return 'badip-' . self::filterEvilInput($input, self::HEX_EXTENDED);
724
-      }
725
-      return inet_ntop($in_addr);
724
+        }
725
+        return inet_ntop($in_addr);
726 726
     }
727 727
 
728 728
     /**
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 class Request {
11
-    const MAXMEMORYUSAGE = 0.9;     // use max. 90% of allowed memory when syncing
11
+    const MAXMEMORYUSAGE = 0.9; // use max. 90% of allowed memory when syncing
12 12
     const UNKNOWN = "unknown";
13 13
     const IMPERSONATE_DELIM = '#';
14 14
 
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
         self::$output = fopen("php://output", "w+");
81 81
 
82 82
         // Parse the standard GET parameters
83
-        if(isset($_GET["Cmd"]))
83
+        if (isset($_GET["Cmd"]))
84 84
             self::$command = self::filterEvilInput($_GET["Cmd"], self::LETTERS_ONLY);
85 85
 
86 86
         // getUser is unfiltered, as everything is allowed.. even "/", "\" or ".."
87
-        if(isset($_GET["User"])) {
87
+        if (isset($_GET["User"])) {
88 88
             self::$getUser = strtolower($_GET["User"]);
89
-            if(defined('USE_FULLEMAIL_FOR_LOGIN') && ! USE_FULLEMAIL_FOR_LOGIN) {
89
+            if (defined('USE_FULLEMAIL_FOR_LOGIN') && !USE_FULLEMAIL_FOR_LOGIN) {
90 90
                 self::$getUser = Utils::GetLocalPartFromEmail(self::$getUser);
91 91
             }
92 92
         }
93
-        if(isset($_GET["DeviceId"]))
93
+        if (isset($_GET["DeviceId"]))
94 94
             self::$devid = strtolower(self::filterEvilInput($_GET["DeviceId"], self::WORDCHAR_ONLY));
95
-        if(isset($_GET["DeviceType"]))
95
+        if (isset($_GET["DeviceType"]))
96 96
             self::$devtype = self::filterEvilInput($_GET["DeviceType"], self::LETTERS_ONLY);
97 97
         if (isset($_GET["AttachmentName"]))
98 98
             self::$attachmentName = self::filterEvilInput($_GET["AttachmentName"], self::HEX_EXTENDED2);
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
         if (isset($_GET["SaveInSent"]) && $_GET["SaveInSent"] == "T")
104 104
             self::$saveInSent = true;
105 105
 
106
-        if(isset($_SERVER["REQUEST_METHOD"]))
106
+        if (isset($_SERVER["REQUEST_METHOD"]))
107 107
             self::$method = self::filterEvilInput($_SERVER["REQUEST_METHOD"], self::LETTERS_ONLY);
108 108
         // TODO check IPv6 addresses
109
-        if(isset($_SERVER["REMOTE_ADDR"]))
109
+        if (isset($_SERVER["REMOTE_ADDR"]))
110 110
             self::$remoteAddr = self::filterIP($_SERVER["REMOTE_ADDR"]);
111 111
 
112 112
         // in protocol version > 14 mobile send these inputs as encoded query string
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
             if (!isset(self::$getUser) && isset(self::$base64QueryDecoded[self::COMMANDPARAM_USER])) {
119 119
                 self::$getUser = strtolower(self::$base64QueryDecoded[self::COMMANDPARAM_USER]);
120
-                if(defined('USE_FULLEMAIL_FOR_LOGIN') && ! USE_FULLEMAIL_FOR_LOGIN) {
120
+                if (defined('USE_FULLEMAIL_FOR_LOGIN') && !USE_FULLEMAIL_FOR_LOGIN) {
121 121
                     self::$getUser = Utils::GetLocalPartFromEmail(self::$getUser);
122 122
                 }
123 123
             }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
                 self::$devtype = self::filterEvilInput(self::$base64QueryDecoded['DevType'], self::LETTERS_ONLY);
130 130
 
131 131
             if (isset(self::$base64QueryDecoded['PolKey']))
132
-                self::$policykey = (int) self::filterEvilInput(self::$base64QueryDecoded['PolKey'], self::NUMBERS_ONLY);
132
+                self::$policykey = (int)self::filterEvilInput(self::$base64QueryDecoded['PolKey'], self::NUMBERS_ONLY);
133 133
 
134 134
             if (isset(self::$base64QueryDecoded['ProtVer']))
135 135
                 self::$asProtocolVersion = self::filterEvilInput(self::$base64QueryDecoded['ProtVer'], self::NUMBERS_ONLY) / 10;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         // in base64 encoded query string user is not necessarily set
154 154
         if (!isset(self::$getUser) && isset($_SERVER['PHP_AUTH_USER'])) {
155 155
             list(self::$getUser,) = Utils::SplitDomainUser(strtolower($_SERVER['PHP_AUTH_USER']));
156
-            if(defined('USE_FULLEMAIL_FOR_LOGIN') && ! USE_FULLEMAIL_FOR_LOGIN) {
156
+            if (defined('USE_FULLEMAIL_FOR_LOGIN') && !USE_FULLEMAIL_FOR_LOGIN) {
157 157
                 self::$getUser = Utils::GetLocalPartFromEmail(self::$getUser);
158 158
             }
159 159
         }
@@ -162,13 +162,13 @@  discard block
 block discarded – undo
162 162
         // split username & domain if received as one
163 163
         if (isset($_SERVER['PHP_AUTH_USER'])) {
164 164
             list(self::$authUserString, self::$authDomain) = Utils::SplitDomainUser($_SERVER['PHP_AUTH_USER']);
165
-            self::$authPassword = (isset($_SERVER['PHP_AUTH_PW']))?$_SERVER['PHP_AUTH_PW'] : "";
165
+            self::$authPassword = (isset($_SERVER['PHP_AUTH_PW'])) ? $_SERVER['PHP_AUTH_PW'] : "";
166 166
         }
167 167
 
168 168
         // process impersonation
169 169
         self::$authUser = self::$authUserString;
170 170
 
171
-        if(defined('USE_FULLEMAIL_FOR_LOGIN') && ! USE_FULLEMAIL_FOR_LOGIN) {
171
+        if (defined('USE_FULLEMAIL_FOR_LOGIN') && !USE_FULLEMAIL_FOR_LOGIN) {
172 172
             self::$authUser = Utils::GetLocalPartFromEmail(self::$authUser);
173 173
         }
174 174
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         }
180 180
         else {
181 181
             preg_replace_callback('/(\-?\d+)(.?)/',
182
-                    function ($m) {
182
+                    function($m) {
183 183
                         self::$memoryLimit = $m[1] * pow(1024, strpos('BKMG', $m[2])) * self::MAXMEMORYUSAGE;
184 184
                     },
185 185
                     strtoupper($memoryLimit));
@@ -194,15 +194,15 @@  discard block
 block discarded – undo
194 194
      */
195 195
     static public function ProcessHeaders() {
196 196
         self::$headers = array_change_key_case(apache_request_headers(), CASE_LOWER);
197
-        self::$useragent = (isset(self::$headers["user-agent"]))? self::$headers["user-agent"] : self::UNKNOWN;
197
+        self::$useragent = (isset(self::$headers["user-agent"])) ? self::$headers["user-agent"] : self::UNKNOWN;
198 198
         if (!isset(self::$asProtocolVersion))
199
-            self::$asProtocolVersion = (isset(self::$headers["ms-asprotocolversion"]))? self::filterEvilInput(self::$headers["ms-asprotocolversion"], self::NUMBERSDOT_ONLY) : ZPush::GetLatestSupportedASVersion();
199
+            self::$asProtocolVersion = (isset(self::$headers["ms-asprotocolversion"])) ? self::filterEvilInput(self::$headers["ms-asprotocolversion"], self::NUMBERSDOT_ONLY) : ZPush::GetLatestSupportedASVersion();
200 200
 
201 201
         //if policykey is not yet set, try to set it from the header
202 202
         //the policy key might be set in Request::Initialize from the base64 encoded query
203 203
         if (!isset(self::$policykey)) {
204 204
             if (isset(self::$headers["x-ms-policykey"]))
205
-                self::$policykey = (int) self::filterEvilInput(self::$headers["x-ms-policykey"], self::NUMBERS_ONLY);
205
+                self::$policykey = (int)self::filterEvilInput(self::$headers["x-ms-policykey"], self::NUMBERS_ONLY);
206 206
             else
207 207
                 self::$policykey = 0;
208 208
         }
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      * @return int
621 621
      */
622 622
     static public function GetContentLength() {
623
-        return (isset(self::$headers["content-length"]))? (int) self::$headers["content-length"] : 0;
623
+        return (isset(self::$headers["content-length"])) ? (int)self::$headers["content-length"] : 0;
624 624
     }
625 625
 
626 626
     /**
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
     static private function filterIP($input) {
721 721
       $in_addr = @inet_pton($input);
722 722
       if ($in_addr === false) {
723
-        return 'badip-' . self::filterEvilInput($input, self::HEX_EXTENDED);
723
+        return 'badip-'.self::filterEvilInput($input, self::HEX_EXTENDED);
724 724
       }
725 725
       return inet_ntop($in_addr);
726 726
     }
@@ -768,10 +768,10 @@  discard block
 block discarded – undo
768 768
          */
769 769
         $decoded = base64_decode($_SERVER['QUERY_STRING']);
770 770
         $devIdLength = ord($decoded[4]); //device ID length
771
-        $polKeyLength = ord($decoded[5+$devIdLength]); //policy key length
772
-        $devTypeLength = ord($decoded[6+$devIdLength+$polKeyLength]); //device type length
771
+        $polKeyLength = ord($decoded[5 + $devIdLength]); //policy key length
772
+        $devTypeLength = ord($decoded[6 + $devIdLength + $polKeyLength]); //device type length
773 773
         //unpack the decoded query string values
774
-        self::$base64QueryDecoded = unpack("CProtVer/CCommand/vLocale/CDevIDLen/H".($devIdLength*2)."DevID/CPolKeyLen".($polKeyLength == 4 ? "/VPolKey" : "")."/CDevTypeLen/A".($devTypeLength)."DevType", $decoded);
774
+        self::$base64QueryDecoded = unpack("CProtVer/CCommand/vLocale/CDevIDLen/H".($devIdLength * 2)."DevID/CPolKeyLen".($polKeyLength == 4 ? "/VPolKey" : "")."/CDevTypeLen/A".($devTypeLength)."DevType", $decoded);
775 775
 
776 776
         //get the command parameters
777 777
         $pos = 7 + $devIdLength + $polKeyLength + $devTypeLength;
Please login to merge, or discard this patch.
Braces   +193 added lines, -141 removed lines patch added patch discarded remove patch
@@ -80,8 +80,9 @@  discard block
 block discarded – undo
80 80
         self::$output = fopen("php://output", "w+");
81 81
 
82 82
         // Parse the standard GET parameters
83
-        if(isset($_GET["Cmd"]))
84
-            self::$command = self::filterEvilInput($_GET["Cmd"], self::LETTERS_ONLY);
83
+        if(isset($_GET["Cmd"])) {
84
+                    self::$command = self::filterEvilInput($_GET["Cmd"], self::LETTERS_ONLY);
85
+        }
85 86
 
86 87
         // getUser is unfiltered, as everything is allowed.. even "/", "\" or ".."
87 88
         if(isset($_GET["User"])) {
@@ -90,30 +91,39 @@  discard block
 block discarded – undo
90 91
                 self::$getUser = Utils::GetLocalPartFromEmail(self::$getUser);
91 92
             }
92 93
         }
93
-        if(isset($_GET["DeviceId"]))
94
-            self::$devid = strtolower(self::filterEvilInput($_GET["DeviceId"], self::WORDCHAR_ONLY));
95
-        if(isset($_GET["DeviceType"]))
96
-            self::$devtype = self::filterEvilInput($_GET["DeviceType"], self::LETTERS_ONLY);
97
-        if (isset($_GET["AttachmentName"]))
98
-            self::$attachmentName = self::filterEvilInput($_GET["AttachmentName"], self::HEX_EXTENDED2);
99
-        if (isset($_GET["CollectionId"]))
100
-            self::$collectionId = self::filterEvilInput($_GET["CollectionId"], self::HEX_EXTENDED2);
101
-        if (isset($_GET["ItemId"]))
102
-            self::$itemId = self::filterEvilInput($_GET["ItemId"], self::HEX_EXTENDED2);
103
-        if (isset($_GET["SaveInSent"]) && $_GET["SaveInSent"] == "T")
104
-            self::$saveInSent = true;
105
-
106
-        if(isset($_SERVER["REQUEST_METHOD"]))
107
-            self::$method = self::filterEvilInput($_SERVER["REQUEST_METHOD"], self::LETTERS_ONLY);
94
+        if(isset($_GET["DeviceId"])) {
95
+                    self::$devid = strtolower(self::filterEvilInput($_GET["DeviceId"], self::WORDCHAR_ONLY));
96
+        }
97
+        if(isset($_GET["DeviceType"])) {
98
+                    self::$devtype = self::filterEvilInput($_GET["DeviceType"], self::LETTERS_ONLY);
99
+        }
100
+        if (isset($_GET["AttachmentName"])) {
101
+                    self::$attachmentName = self::filterEvilInput($_GET["AttachmentName"], self::HEX_EXTENDED2);
102
+        }
103
+        if (isset($_GET["CollectionId"])) {
104
+                    self::$collectionId = self::filterEvilInput($_GET["CollectionId"], self::HEX_EXTENDED2);
105
+        }
106
+        if (isset($_GET["ItemId"])) {
107
+                    self::$itemId = self::filterEvilInput($_GET["ItemId"], self::HEX_EXTENDED2);
108
+        }
109
+        if (isset($_GET["SaveInSent"]) && $_GET["SaveInSent"] == "T") {
110
+                    self::$saveInSent = true;
111
+        }
112
+
113
+        if(isset($_SERVER["REQUEST_METHOD"])) {
114
+                    self::$method = self::filterEvilInput($_SERVER["REQUEST_METHOD"], self::LETTERS_ONLY);
115
+        }
108 116
         // TODO check IPv6 addresses
109
-        if(isset($_SERVER["REMOTE_ADDR"]))
110
-            self::$remoteAddr = self::filterIP($_SERVER["REMOTE_ADDR"]);
117
+        if(isset($_SERVER["REMOTE_ADDR"])) {
118
+                    self::$remoteAddr = self::filterIP($_SERVER["REMOTE_ADDR"]);
119
+        }
111 120
 
112 121
         // in protocol version > 14 mobile send these inputs as encoded query string
113 122
         if (!isset(self::$command) && !empty($_SERVER['QUERY_STRING']) && Utils::IsBase64String($_SERVER['QUERY_STRING'])) {
114 123
             self::decodeBase64URI();
115
-            if (!isset(self::$command) && isset(self::$base64QueryDecoded['Command']))
116
-                self::$command = Utils::GetCommandFromCode(self::$base64QueryDecoded['Command']);
124
+            if (!isset(self::$command) && isset(self::$base64QueryDecoded['Command'])) {
125
+                            self::$command = Utils::GetCommandFromCode(self::$base64QueryDecoded['Command']);
126
+            }
117 127
 
118 128
             if (!isset(self::$getUser) && isset(self::$base64QueryDecoded[self::COMMANDPARAM_USER])) {
119 129
                 self::$getUser = strtolower(self::$base64QueryDecoded[self::COMMANDPARAM_USER]);
@@ -122,32 +132,41 @@  discard block
 block discarded – undo
122 132
                 }
123 133
             }
124 134
 
125
-            if (!isset(self::$devid) && isset(self::$base64QueryDecoded['DevID']))
126
-                self::$devid = strtolower(self::filterEvilInput(self::$base64QueryDecoded['DevID'], self::WORDCHAR_ONLY));
135
+            if (!isset(self::$devid) && isset(self::$base64QueryDecoded['DevID'])) {
136
+                            self::$devid = strtolower(self::filterEvilInput(self::$base64QueryDecoded['DevID'], self::WORDCHAR_ONLY));
137
+            }
127 138
 
128
-            if (!isset(self::$devtype) && isset(self::$base64QueryDecoded['DevType']))
129
-                self::$devtype = self::filterEvilInput(self::$base64QueryDecoded['DevType'], self::LETTERS_ONLY);
139
+            if (!isset(self::$devtype) && isset(self::$base64QueryDecoded['DevType'])) {
140
+                            self::$devtype = self::filterEvilInput(self::$base64QueryDecoded['DevType'], self::LETTERS_ONLY);
141
+            }
130 142
 
131
-            if (isset(self::$base64QueryDecoded['PolKey']))
132
-                self::$policykey = (int) self::filterEvilInput(self::$base64QueryDecoded['PolKey'], self::NUMBERS_ONLY);
143
+            if (isset(self::$base64QueryDecoded['PolKey'])) {
144
+                            self::$policykey = (int) self::filterEvilInput(self::$base64QueryDecoded['PolKey'], self::NUMBERS_ONLY);
145
+            }
133 146
 
134
-            if (isset(self::$base64QueryDecoded['ProtVer']))
135
-                self::$asProtocolVersion = self::filterEvilInput(self::$base64QueryDecoded['ProtVer'], self::NUMBERS_ONLY) / 10;
147
+            if (isset(self::$base64QueryDecoded['ProtVer'])) {
148
+                            self::$asProtocolVersion = self::filterEvilInput(self::$base64QueryDecoded['ProtVer'], self::NUMBERS_ONLY) / 10;
149
+            }
136 150
 
137
-            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_ATTACHMENTNAME]))
138
-                self::$attachmentName = self::filterEvilInput(self::$base64QueryDecoded[self::COMMANDPARAM_ATTACHMENTNAME], self::HEX_EXTENDED2);
151
+            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_ATTACHMENTNAME])) {
152
+                            self::$attachmentName = self::filterEvilInput(self::$base64QueryDecoded[self::COMMANDPARAM_ATTACHMENTNAME], self::HEX_EXTENDED2);
153
+            }
139 154
 
140
-            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_COLLECTIONID]))
141
-                self::$collectionId = self::filterEvilInput(self::$base64QueryDecoded[self::COMMANDPARAM_COLLECTIONID], self::HEX_EXTENDED2);
155
+            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_COLLECTIONID])) {
156
+                            self::$collectionId = self::filterEvilInput(self::$base64QueryDecoded[self::COMMANDPARAM_COLLECTIONID], self::HEX_EXTENDED2);
157
+            }
142 158
 
143
-            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_ITEMID]))
144
-                self::$itemId = self::filterEvilInput(self::$base64QueryDecoded[self::COMMANDPARAM_ITEMID], self::HEX_EXTENDED2);
159
+            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_ITEMID])) {
160
+                            self::$itemId = self::filterEvilInput(self::$base64QueryDecoded[self::COMMANDPARAM_ITEMID], self::HEX_EXTENDED2);
161
+            }
145 162
 
146
-            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_OPTIONS]) && (ord(self::$base64QueryDecoded[self::COMMANDPARAM_OPTIONS]) & self::COMMANDPARAM_OPTIONS_SAVEINSENT))
147
-                self::$saveInSent = true;
163
+            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_OPTIONS]) && (ord(self::$base64QueryDecoded[self::COMMANDPARAM_OPTIONS]) & self::COMMANDPARAM_OPTIONS_SAVEINSENT)) {
164
+                            self::$saveInSent = true;
165
+            }
148 166
 
149
-            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_OPTIONS]) && (ord(self::$base64QueryDecoded[self::COMMANDPARAM_OPTIONS]) & self::COMMANDPARAM_OPTIONS_ACCEPTMULTIPART))
150
-                self::$acceptMultipart = true;
167
+            if (isset(self::$base64QueryDecoded[self::COMMANDPARAM_OPTIONS]) && (ord(self::$base64QueryDecoded[self::COMMANDPARAM_OPTIONS]) & self::COMMANDPARAM_OPTIONS_ACCEPTMULTIPART)) {
168
+                            self::$acceptMultipart = true;
169
+            }
151 170
         }
152 171
 
153 172
         // in base64 encoded query string user is not necessarily set
@@ -176,8 +195,7 @@  discard block
 block discarded – undo
176 195
         $memoryLimit = ini_get('memory_limit');
177 196
         if ($memoryLimit == -1) {
178 197
             self::$memoryLimit = false;
179
-        }
180
-        else {
198
+        } else {
181 199
             preg_replace_callback('/(\-?\d+)(.?)/',
182 200
                     function ($m) {
183 201
                         self::$memoryLimit = $m[1] * pow(1024, strpos('BKMG', $m[2])) * self::MAXMEMORYUSAGE;
@@ -195,25 +213,29 @@  discard block
 block discarded – undo
195 213
     static public function ProcessHeaders() {
196 214
         self::$headers = array_change_key_case(apache_request_headers(), CASE_LOWER);
197 215
         self::$useragent = (isset(self::$headers["user-agent"]))? self::$headers["user-agent"] : self::UNKNOWN;
198
-        if (!isset(self::$asProtocolVersion))
199
-            self::$asProtocolVersion = (isset(self::$headers["ms-asprotocolversion"]))? self::filterEvilInput(self::$headers["ms-asprotocolversion"], self::NUMBERSDOT_ONLY) : ZPush::GetLatestSupportedASVersion();
216
+        if (!isset(self::$asProtocolVersion)) {
217
+                    self::$asProtocolVersion = (isset(self::$headers["ms-asprotocolversion"]))? self::filterEvilInput(self::$headers["ms-asprotocolversion"], self::NUMBERSDOT_ONLY) : ZPush::GetLatestSupportedASVersion();
218
+        }
200 219
 
201 220
         //if policykey is not yet set, try to set it from the header
202 221
         //the policy key might be set in Request::Initialize from the base64 encoded query
203 222
         if (!isset(self::$policykey)) {
204
-            if (isset(self::$headers["x-ms-policykey"]))
205
-                self::$policykey = (int) self::filterEvilInput(self::$headers["x-ms-policykey"], self::NUMBERS_ONLY);
206
-            else
207
-                self::$policykey = 0;
223
+            if (isset(self::$headers["x-ms-policykey"])) {
224
+                            self::$policykey = (int) self::filterEvilInput(self::$headers["x-ms-policykey"], self::NUMBERS_ONLY);
225
+            } else {
226
+                            self::$policykey = 0;
227
+            }
208 228
         }
209 229
 
210 230
         if (isset(self::$base64QueryDecoded)) {
211 231
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("Request::ProcessHeaders(): base64 query string: '%s' (decoded: '%s')", $_SERVER['QUERY_STRING'], http_build_query(self::$base64QueryDecoded, '', ',')));
212
-            if (isset(self::$policykey))
213
-                self::$headers["x-ms-policykey"] = self::$policykey;
232
+            if (isset(self::$policykey)) {
233
+                            self::$headers["x-ms-policykey"] = self::$policykey;
234
+            }
214 235
 
215
-            if (isset(self::$asProtocolVersion))
216
-                self::$headers["ms-asprotocolversion"] = self::$asProtocolVersion;
236
+            if (isset(self::$asProtocolVersion)) {
237
+                            self::$headers["ms-asprotocolversion"] = self::$asProtocolVersion;
238
+            }
217 239
         }
218 240
 
219 241
         if (!isset(self::$acceptMultipart) && isset(self::$headers["ms-asacceptmultipart"]) && strtoupper(self::$headers["ms-asacceptmultipart"]) == "T") {
@@ -265,10 +287,11 @@  discard block
 block discarded – undo
265 287
      * @return handle/boolean      false if not available
266 288
      */
267 289
     static public function GetInputStream() {
268
-        if (isset(self::$input))
269
-            return self::$input;
270
-        else
271
-            return false;
290
+        if (isset(self::$input)) {
291
+                    return self::$input;
292
+        } else {
293
+                    return false;
294
+        }
272 295
     }
273 296
 
274 297
     /**
@@ -278,10 +301,11 @@  discard block
 block discarded – undo
278 301
      * @return handle/boolean      false if not available
279 302
      */
280 303
     static public function GetOutputStream() {
281
-        if (isset(self::$output))
282
-            return self::$output;
283
-        else
284
-            return false;
304
+        if (isset(self::$output)) {
305
+                    return self::$output;
306
+        } else {
307
+                    return false;
308
+        }
285 309
     }
286 310
 
287 311
     /**
@@ -291,10 +315,11 @@  discard block
 block discarded – undo
291 315
      * @return string
292 316
      */
293 317
     static public function GetMethod() {
294
-        if (isset(self::$method))
295
-            return self::$method;
296
-        else
297
-            return self::UNKNOWN;
318
+        if (isset(self::$method)) {
319
+                    return self::$method;
320
+        } else {
321
+                    return self::UNKNOWN;
322
+        }
298 323
     }
299 324
 
300 325
     /**
@@ -304,10 +329,11 @@  discard block
 block discarded – undo
304 329
      * @return string/boolean       false if not available
305 330
      */
306 331
     static public function GetGETUser() {
307
-        if (isset(self::$getUser))
308
-            return self::$getUser;
309
-        else
310
-            return self::UNKNOWN;
332
+        if (isset(self::$getUser)) {
333
+                    return self::$getUser;
334
+        } else {
335
+                    return self::UNKNOWN;
336
+        }
311 337
     }
312 338
 
313 339
     /**
@@ -317,10 +343,11 @@  discard block
 block discarded – undo
317 343
      * @return string/boolean       false if not available
318 344
      */
319 345
     static public function GetGETItemId() {
320
-        if (isset(self::$itemId))
321
-            return self::$itemId;
322
-        else
323
-            return false;
346
+        if (isset(self::$itemId)) {
347
+                    return self::$itemId;
348
+        } else {
349
+                    return false;
350
+        }
324 351
         }
325 352
 
326 353
     /**
@@ -330,10 +357,11 @@  discard block
 block discarded – undo
330 357
      * @return string/boolean       false if not available
331 358
      */
332 359
     static public function GetGETCollectionId() {
333
-        if (isset(self::$collectionId))
334
-            return self::$collectionId;
335
-        else
336
-            return false;
360
+        if (isset(self::$collectionId)) {
361
+                    return self::$collectionId;
362
+        } else {
363
+                    return false;
364
+        }
337 365
     }
338 366
 
339 367
     /**
@@ -343,10 +371,11 @@  discard block
 block discarded – undo
343 371
      * @return boolean
344 372
      */
345 373
     static public function GetGETSaveInSent() {
346
-        if (isset(self::$saveInSent))
347
-            return self::$saveInSent;
348
-        else
349
-            return true;
374
+        if (isset(self::$saveInSent)) {
375
+                    return self::$saveInSent;
376
+        } else {
377
+                    return true;
378
+        }
350 379
     }
351 380
 
352 381
     /**
@@ -356,10 +385,11 @@  discard block
 block discarded – undo
356 385
     * @return boolean
357 386
     */
358 387
     static public function GetGETAcceptMultipart() {
359
-        if (isset(self::$acceptMultipart))
360
-            return self::$acceptMultipart;
361
-        else
362
-            return false;
388
+        if (isset(self::$acceptMultipart)) {
389
+                    return self::$acceptMultipart;
390
+        } else {
391
+                    return false;
392
+        }
363 393
     }
364 394
 
365 395
     /**
@@ -369,10 +399,11 @@  discard block
 block discarded – undo
369 399
      * @return string/boolean       false if not available
370 400
      */
371 401
     static public function GetGETAttachmentName() {
372
-        if (isset(self::$attachmentName))
373
-            return self::$attachmentName;
374
-        else
375
-            return false;
402
+        if (isset(self::$attachmentName)) {
403
+                    return self::$attachmentName;
404
+        } else {
405
+                    return false;
406
+        }
376 407
     }
377 408
 
378 409
     /**
@@ -436,10 +467,11 @@  discard block
 block discarded – undo
436 467
      * @return string/boolean       false if not available
437 468
      */
438 469
     static public function GetAuthDomain() {
439
-        if (isset(self::$authDomain))
440
-            return self::$authDomain;
441
-        else
442
-            return false;
470
+        if (isset(self::$authDomain)) {
471
+                    return self::$authDomain;
472
+        } else {
473
+                    return false;
474
+        }
443 475
     }
444 476
 
445 477
     /**
@@ -449,10 +481,11 @@  discard block
 block discarded – undo
449 481
      * @return string/boolean       false if not available
450 482
      */
451 483
     static public function GetAuthPassword() {
452
-        if (isset(self::$authPassword))
453
-            return self::$authPassword;
454
-        else
455
-            return false;
484
+        if (isset(self::$authPassword)) {
485
+                    return self::$authPassword;
486
+        } else {
487
+                    return false;
488
+        }
456 489
     }
457 490
 
458 491
     /**
@@ -462,10 +495,11 @@  discard block
 block discarded – undo
462 495
      * @return string
463 496
      */
464 497
     static public function GetRemoteAddr() {
465
-        if (isset(self::$remoteAddr))
466
-            return self::$remoteAddr;
467
-        else
468
-            return "UNKNOWN";
498
+        if (isset(self::$remoteAddr)) {
499
+                    return self::$remoteAddr;
500
+        } else {
501
+                    return "UNKNOWN";
502
+        }
469 503
     }
470 504
 
471 505
     /**
@@ -475,10 +509,11 @@  discard block
 block discarded – undo
475 509
      * @return string/boolean       false if not available
476 510
      */
477 511
     static public function GetCommand() {
478
-        if (isset(self::$command))
479
-            return self::$command;
480
-        else
481
-            return false;
512
+        if (isset(self::$command)) {
513
+                    return self::$command;
514
+        } else {
515
+                    return false;
516
+        }
482 517
     }
483 518
 
484 519
     /**
@@ -488,10 +523,11 @@  discard block
 block discarded – undo
488 523
      * @return string/boolean       false if not available
489 524
      */
490 525
     static public function GetCommandCode() {
491
-        if (isset(self::$command))
492
-            return Utils::GetCodeFromCommand(self::$command);
493
-        else
494
-            return false;
526
+        if (isset(self::$command)) {
527
+                    return Utils::GetCodeFromCommand(self::$command);
528
+        } else {
529
+                    return false;
530
+        }
495 531
     }
496 532
 
497 533
     /**
@@ -501,10 +537,11 @@  discard block
 block discarded – undo
501 537
      * @return string/boolean       false if not available
502 538
      */
503 539
     static public function GetDeviceID() {
504
-        if (isset(self::$devid))
505
-            return self::$devid;
506
-        else
507
-            return false;
540
+        if (isset(self::$devid)) {
541
+                    return self::$devid;
542
+        } else {
543
+                    return false;
544
+        }
508 545
     }
509 546
 
510 547
     /**
@@ -514,10 +551,11 @@  discard block
 block discarded – undo
514 551
      * @return string/boolean       false if not available
515 552
      */
516 553
     static public function GetDeviceType() {
517
-        if (isset(self::$devtype))
518
-            return self::$devtype;
519
-        else
520
-            return false;
554
+        if (isset(self::$devtype)) {
555
+                    return self::$devtype;
556
+        } else {
557
+                    return false;
558
+        }
521 559
     }
522 560
 
523 561
     /**
@@ -527,10 +565,11 @@  discard block
 block discarded – undo
527 565
      * @return string/boolean       false if not available
528 566
      */
529 567
     static public function GetProtocolVersion() {
530
-        if (isset(self::$asProtocolVersion))
531
-            return self::$asProtocolVersion;
532
-        else
533
-            return false;
568
+        if (isset(self::$asProtocolVersion)) {
569
+                    return self::$asProtocolVersion;
570
+        } else {
571
+                    return false;
572
+        }
534 573
     }
535 574
 
536 575
     /**
@@ -540,10 +579,11 @@  discard block
 block discarded – undo
540 579
      * @return string/boolean       false if not available
541 580
      */
542 581
     static public function GetUserAgent() {
543
-        if (isset(self::$useragent))
544
-            return self::$useragent;
545
-        else
546
-            return self::UNKNOWN;
582
+        if (isset(self::$useragent)) {
583
+                    return self::$useragent;
584
+        } else {
585
+                    return self::UNKNOWN;
586
+        }
547 587
     }
548 588
 
549 589
     /**
@@ -553,10 +593,11 @@  discard block
 block discarded – undo
553 593
      * @return int/boolean       false if not available
554 594
      */
555 595
     static public function GetPolicyKey() {
556
-        if (isset(self::$policykey))
557
-            return self::$policykey;
558
-        else
559
-            return false;
596
+        if (isset(self::$policykey)) {
597
+                    return self::$policykey;
598
+        } else {
599
+                    return false;
600
+        }
560 601
     }
561 602
 
562 603
     /**
@@ -607,10 +648,11 @@  discard block
 block discarded – undo
607 648
      * @return boolean       false if invalid
608 649
      */
609 650
     static public function IsValidDeviceID() {
610
-        if (self::GetDeviceID() === "validate")
611
-            return false;
612
-        else
613
-            return true;
651
+        if (self::GetDeviceID() === "validate") {
652
+                    return false;
653
+        } else {
654
+                    return true;
655
+        }
614 656
     }
615 657
 
616 658
     /**
@@ -645,8 +687,7 @@  discard block
 block discarded – undo
645 687
             // Samsung devices have a intermediate timeout (90sec)
646 688
             else if (stripos(SYNC_TIMEOUT_MEDIUM_DEVICETYPES, self::GetDeviceType()) !== false) {
647 689
                 self::$expectedConnectionTimeout = 85;
648
-            }
649
-            else {
690
+            } else {
650 691
                 // for all other devices, a timeout of 30 seconds is expected
651 692
                 self::$expectedConnectionTimeout = 28;
652 693
             }
@@ -696,14 +737,25 @@  discard block
 block discarded – undo
696 737
      */
697 738
     static private function filterEvilInput($input, $filter, $replacevalue = '') {
698 739
         $re = false;
699
-        if ($filter == self::LETTERS_ONLY)          $re = "/[^A-Za-z]/";
700
-        elseif ($filter == self::HEX_ONLY)          $re = "/[^A-Fa-f0-9]/";
701
-        elseif ($filter == self::WORDCHAR_ONLY)     $re = "/[^A-Za-z0-9]/";
702
-        elseif ($filter == self::NUMBERS_ONLY)      $re = "/[^0-9]/";
703
-        elseif ($filter == self::NUMBERSDOT_ONLY)   $re = "/[^0-9\.]/";
704
-        elseif ($filter == self::HEX_EXTENDED)      $re = "/[^A-Fa-f0-9\:\.]/";
705
-        elseif ($filter == self::HEX_EXTENDED2)     $re = "/[^A-Fa-f0-9\:USGI]/"; // Folder origin constants from DeviceManager::FLD_ORIGIN_* (C already hex)
706
-        elseif ($filter == self::ISO8601)           $re = "/[^\d{8}T\d{6}Z]/";
740
+        if ($filter == self::LETTERS_ONLY) {
741
+            $re = "/[^A-Za-z]/";
742
+        } elseif ($filter == self::HEX_ONLY) {
743
+            $re = "/[^A-Fa-f0-9]/";
744
+        } elseif ($filter == self::WORDCHAR_ONLY) {
745
+            $re = "/[^A-Za-z0-9]/";
746
+        } elseif ($filter == self::NUMBERS_ONLY) {
747
+            $re = "/[^0-9]/";
748
+        } elseif ($filter == self::NUMBERSDOT_ONLY) {
749
+            $re = "/[^0-9\.]/";
750
+        } elseif ($filter == self::HEX_EXTENDED) {
751
+            $re = "/[^A-Fa-f0-9\:\.]/";
752
+        } elseif ($filter == self::HEX_EXTENDED2) {
753
+            $re = "/[^A-Fa-f0-9\:USGI]/";
754
+        }
755
+        // Folder origin constants from DeviceManager::FLD_ORIGIN_* (C already hex)
756
+        elseif ($filter == self::ISO8601) {
757
+            $re = "/[^\d{8}T\d{6}Z]/";
758
+        }
707 759
 
708 760
         return ($re) ? preg_replace($re, $replacevalue, $input) : '';
709 761
     }
Please login to merge, or discard this patch.
lib/request/settings.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         // - UserInformation
32 32
         // Each of them should only be once per request. Each property must be processed in order.
33 33
         WBXMLDecoder::ResetInWhile("settingsMain");
34
-        while(WBXMLDecoder::InWhile("settingsMain")) {
34
+        while (WBXMLDecoder::InWhile("settingsMain")) {
35 35
             $propertyName = "";
36 36
             if (self::$decoder->getElementStartTag(SYNC_SETTINGS_OOF)) {
37 37
                 $propertyName = SYNC_SETTINGS_OOF;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                     case SYNC_SETTINGS_OOF:
61 61
                         $oofGet = new SyncOOF();
62 62
                         $oofGet->Decode(self::$decoder);
63
-                        if(!self::$decoder->getElementEndTag())
63
+                        if (!self::$decoder->getElementEndTag())
64 64
                             return false; // SYNC_SETTINGS_GET
65 65
                         break;
66 66
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
                     default:
76 76
                         //TODO: a special status code needed?
77
-                        ZLog::Write(LOGLEVEL_WARN, sprintf ("This property ('%s') is not allowed to use get in request", $propertyName));
77
+                        ZLog::Write(LOGLEVEL_WARN, sprintf("This property ('%s') is not allowed to use get in request", $propertyName));
78 78
                 }
79 79
             }
80 80
             elseif (self::$decoder->getElementStartTag(SYNC_SETTINGS_SET)) {
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 
102 102
                     default:
103 103
                         //TODO: a special status code needed?
104
-                        ZLog::Write(LOGLEVEL_WARN, sprintf ("This property ('%s') is not allowed to use set in request", $propertyName));
104
+                        ZLog::Write(LOGLEVEL_WARN, sprintf("This property ('%s') is not allowed to use set in request", $propertyName));
105 105
                 }
106 106
 
107
-                if(!self::$decoder->getElementEndTag())
107
+                if (!self::$decoder->getElementEndTag())
108 108
                     return false; // SYNC_SETTINGS_SET
109 109
             }
110 110
             else {
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
                 return false;
113 113
             }
114 114
 
115
-            if(!self::$decoder->getElementEndTag())
115
+            if (!self::$decoder->getElementEndTag())
116 116
                 return false; // SYNC_SETTINGS_OOF or SYNC_SETTINGS_DEVICEPW or SYNC_SETTINGS_DEVICEINFORMATION or SYNC_SETTINGS_USERINFORMATION
117 117
 
118 118
             //break if it reached the endtag
119 119
             $e = self::$decoder->peek();
120
-            if($e[EN_TYPE] == EN_TYPE_ENDTAG) {
120
+            if ($e[EN_TYPE] == EN_TYPE_ENDTAG) {
121 121
                 self::$decoder->getElementEndTag(); //SYNC_SETTINGS_SETTINGS
122 122
                 break;
123 123
             }
Please login to merge, or discard this patch.
Braces   +20 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@  discard block
 block discarded – undo
18 18
      * @return boolean
19 19
      */
20 20
     public function Handle($commandCode) {
21
-        if (!self::$decoder->getElementStartTag(SYNC_SETTINGS_SETTINGS))
22
-            return false;
21
+        if (!self::$decoder->getElementStartTag(SYNC_SETTINGS_SETTINGS)) {
22
+                    return false;
23
+        }
23 24
 
24 25
         //save the request parameters
25 26
         $request = array();
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
             }
51 52
             //TODO - check if it is necessary
52 53
             //no property name available - break
53
-            if (!$propertyName)
54
-                break;
54
+            if (!$propertyName) {
55
+                            break;
56
+            }
55 57
 
56 58
             //the property name is followed by either get or set
57 59
             if (self::$decoder->getElementStartTag(SYNC_SETTINGS_GET)) {
@@ -60,8 +62,10 @@  discard block
 block discarded – undo
60 62
                     case SYNC_SETTINGS_OOF:
61 63
                         $oofGet = new SyncOOF();
62 64
                         $oofGet->Decode(self::$decoder);
63
-                        if(!self::$decoder->getElementEndTag())
64
-                            return false; // SYNC_SETTINGS_GET
65
+                        if(!self::$decoder->getElementEndTag()) {
66
+                                                    return false;
67
+                        }
68
+                        // SYNC_SETTINGS_GET
65 69
                         break;
66 70
 
67 71
                     case SYNC_SETTINGS_USERINFORMATION:
@@ -76,8 +80,7 @@  discard block
 block discarded – undo
76 80
                         //TODO: a special status code needed?
77 81
                         ZLog::Write(LOGLEVEL_WARN, sprintf ("This property ('%s') is not allowed to use get in request", $propertyName));
78 82
                 }
79
-            }
80
-            elseif (self::$decoder->getElementStartTag(SYNC_SETTINGS_SET)) {
83
+            } elseif (self::$decoder->getElementStartTag(SYNC_SETTINGS_SET)) {
81 84
                 //set is available for OOF, device password and device information
82 85
                 switch ($propertyName) {
83 86
                     case SYNC_SETTINGS_OOF:
@@ -104,16 +107,19 @@  discard block
 block discarded – undo
104 107
                         ZLog::Write(LOGLEVEL_WARN, sprintf ("This property ('%s') is not allowed to use set in request", $propertyName));
105 108
                 }
106 109
 
107
-                if(!self::$decoder->getElementEndTag())
108
-                    return false; // SYNC_SETTINGS_SET
109
-            }
110
-            else {
110
+                if(!self::$decoder->getElementEndTag()) {
111
+                                    return false;
112
+                }
113
+                // SYNC_SETTINGS_SET
114
+            } else {
111 115
                 ZLog::Write(LOGLEVEL_WARN, sprintf("Neither get nor set found for property '%s'", $propertyName));
112 116
                 return false;
113 117
             }
114 118
 
115
-            if(!self::$decoder->getElementEndTag())
116
-                return false; // SYNC_SETTINGS_OOF or SYNC_SETTINGS_DEVICEPW or SYNC_SETTINGS_DEVICEINFORMATION or SYNC_SETTINGS_USERINFORMATION
119
+            if(!self::$decoder->getElementEndTag()) {
120
+                            return false;
121
+            }
122
+            // SYNC_SETTINGS_OOF or SYNC_SETTINGS_DEVICEPW or SYNC_SETTINGS_DEVICEINFORMATION or SYNC_SETTINGS_USERINFORMATION
117 123
 
118 124
             //break if it reached the endtag
119 125
             $e = self::$decoder->peek();
Please login to merge, or discard this patch.
lib/syncobjects/syncitemoperationsattachment.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
 
16 16
     function __construct() {
17 17
         $mapping = array(
18
-            SYNC_AIRSYNCBASE_CONTENTTYPE                        => array (  self::STREAMER_VAR      => "contenttype"),
19
-            SYNC_ITEMOPERATIONS_DATA                            => array (  self::STREAMER_VAR      => "data",
18
+            SYNC_AIRSYNCBASE_CONTENTTYPE                        => array(self::STREAMER_VAR      => "contenttype"),
19
+            SYNC_ITEMOPERATIONS_DATA                            => array(self::STREAMER_VAR      => "data",
20 20
                                                                             self::STREAMER_TYPE     => self::STREAMER_TYPE_STREAM_ASBASE64,
21 21
                                                                             self::STREAMER_PROP     => self::STREAMER_TYPE_MULTIPART),
22 22
         );
Please login to merge, or discard this patch.
lib/syncobjects/syncfolder.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,34 +21,34 @@
 block discarded – undo
21 21
     public $TypeReal;
22 22
 
23 23
     function __construct() {
24
-        $mapping = array (
25
-                    SYNC_FOLDERHIERARCHY_SERVERENTRYID                  => array (  self::STREAMER_VAR      => "serverid",
26
-                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED   => false)),
24
+        $mapping = array(
25
+                    SYNC_FOLDERHIERARCHY_SERVERENTRYID                  => array(self::STREAMER_VAR      => "serverid",
26
+                                                                                    self::STREAMER_CHECKS   => array(self::STREAMER_CHECK_REQUIRED   => false)),
27 27
 
28
-                    SYNC_FOLDERHIERARCHY_PARENTID                       => array (  self::STREAMER_VAR      => "parentid",
29
-                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED   => self::STREAMER_CHECK_SETZERO)),
28
+                    SYNC_FOLDERHIERARCHY_PARENTID                       => array(self::STREAMER_VAR      => "parentid",
29
+                                                                                    self::STREAMER_CHECKS   => array(self::STREAMER_CHECK_REQUIRED   => self::STREAMER_CHECK_SETZERO)),
30 30
 
31
-                    SYNC_FOLDERHIERARCHY_DISPLAYNAME                    => array (  self::STREAMER_VAR      => "displayname",
32
-                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED   => "Unknown")),
31
+                    SYNC_FOLDERHIERARCHY_DISPLAYNAME                    => array(self::STREAMER_VAR      => "displayname",
32
+                                                                                    self::STREAMER_CHECKS   => array(self::STREAMER_CHECK_REQUIRED   => "Unknown")),
33 33
 
34
-                    SYNC_FOLDERHIERARCHY_TYPE                           => array (  self::STREAMER_VAR      => "type",
35
-                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED   => 18,
34
+                    SYNC_FOLDERHIERARCHY_TYPE                           => array(self::STREAMER_VAR      => "type",
35
+                                                                                    self::STREAMER_CHECKS   => array(self::STREAMER_CHECK_REQUIRED   => 18,
36 36
                                                                                                                         self::STREAMER_CHECK_CMPHIGHER  => 0,
37
-                                                                                                                        self::STREAMER_CHECK_CMPLOWER   => 20  )),
37
+                                                                                                                        self::STREAMER_CHECK_CMPLOWER   => 20)),
38 38
 
39
-                    SYNC_FOLDERHIERARCHY_IGNORE_STORE                   => array (  self::STREAMER_VAR      => "Store",
39
+                    SYNC_FOLDERHIERARCHY_IGNORE_STORE                   => array(self::STREAMER_VAR      => "Store",
40 40
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_IGNORE),
41 41
 
42
-                    SYNC_FOLDERHIERARCHY_IGNORE_NOBCKENDFLD             => array (  self::STREAMER_VAR      => "NoBackendFolder",
42
+                    SYNC_FOLDERHIERARCHY_IGNORE_NOBCKENDFLD             => array(self::STREAMER_VAR      => "NoBackendFolder",
43 43
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_IGNORE),
44 44
 
45
-                    SYNC_FOLDERHIERARCHY_IGNORE_BACKENDID               => array (  self::STREAMER_VAR      => "BackendId",
45
+                    SYNC_FOLDERHIERARCHY_IGNORE_BACKENDID               => array(self::STREAMER_VAR      => "BackendId",
46 46
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_IGNORE),
47 47
 
48
-                    SYNC_FOLDERHIERARCHY_IGNORE_FLAGS                   => array (  self::STREAMER_VAR      => "Flags",
48
+                    SYNC_FOLDERHIERARCHY_IGNORE_FLAGS                   => array(self::STREAMER_VAR      => "Flags",
49 49
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_IGNORE),
50 50
 
51
-                    SYNC_FOLDERHIERARCHY_IGNORE_TYPEREAL                => array (  self::STREAMER_VAR      => "TypeReal",
51
+                    SYNC_FOLDERHIERARCHY_IGNORE_TYPEREAL                => array(self::STREAMER_VAR      => "TypeReal",
52 52
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_IGNORE),
53 53
         );
54 54
 
Please login to merge, or discard this patch.
lib/syncobjects/synctask.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -29,23 +29,23 @@  discard block
 block discarded – undo
29 29
     public $categories;
30 30
 
31 31
     function __construct() {
32
-        $mapping = array (
33
-                    SYNC_POOMTASKS_BODY                                 => array (  self::STREAMER_VAR      => "body",
32
+        $mapping = array(
33
+                    SYNC_POOMTASKS_BODY                                 => array(self::STREAMER_VAR      => "body",
34 34
                                                                                     self::STREAMER_RONOTIFY => true),
35
-                    SYNC_POOMTASKS_COMPLETE                             => array (  self::STREAMER_VAR      => "complete",
36
-                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETZERO,
37
-                                                                                                                        self::STREAMER_CHECK_ZEROORONE      => self::STREAMER_CHECK_SETZERO ),
35
+                    SYNC_POOMTASKS_COMPLETE                             => array(self::STREAMER_VAR      => "complete",
36
+                                                                                    self::STREAMER_CHECKS   => array(self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETZERO,
37
+                                                                                                                        self::STREAMER_CHECK_ZEROORONE      => self::STREAMER_CHECK_SETZERO),
38 38
                                                                                     self::STREAMER_RONOTIFY => true),
39 39
 
40
-                    SYNC_POOMTASKS_DATECOMPLETED                        => array (  self::STREAMER_VAR      => "datecompleted",
40
+                    SYNC_POOMTASKS_DATECOMPLETED                        => array(self::STREAMER_VAR      => "datecompleted",
41 41
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
42 42
                                                                                     self::STREAMER_RONOTIFY => true),
43 43
 
44
-                    SYNC_POOMTASKS_DUEDATE                              => array (  self::STREAMER_VAR      => "duedate",
44
+                    SYNC_POOMTASKS_DUEDATE                              => array(self::STREAMER_VAR      => "duedate",
45 45
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
46 46
                                                                                     self::STREAMER_RONOTIFY => true),
47 47
 
48
-                    SYNC_POOMTASKS_UTCDUEDATE                           => array (  self::STREAMER_VAR      => "utcduedate",
48
+                    SYNC_POOMTASKS_UTCDUEDATE                           => array(self::STREAMER_VAR      => "utcduedate",
49 49
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
50 50
                                                                                     self::STREAMER_RONOTIFY => true),
51 51
 
@@ -54,25 +54,25 @@  discard block
 block discarded – undo
54 54
                     // 1 = Normal
55 55
                     // 2 = High
56 56
                     // even the default value 1 is optional, the native android client 2.2 interprets a non-existing value as 0 (low)
57
-                    SYNC_POOMTASKS_IMPORTANCE                           => array (  self::STREAMER_VAR      => "importance",
58
-                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETONE,
59
-                                                                                                                        self::STREAMER_CHECK_ONEVALUEOF     => array(0,1,2) ),
57
+                    SYNC_POOMTASKS_IMPORTANCE                           => array(self::STREAMER_VAR      => "importance",
58
+                                                                                    self::STREAMER_CHECKS   => array(self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETONE,
59
+                                                                                                                        self::STREAMER_CHECK_ONEVALUEOF     => array(0, 1, 2)),
60 60
                                                                                     self::STREAMER_RONOTIFY => true),
61 61
 
62
-                    SYNC_POOMTASKS_RECURRENCE                           => array (  self::STREAMER_VAR      => "recurrence",
62
+                    SYNC_POOMTASKS_RECURRENCE                           => array(self::STREAMER_VAR      => "recurrence",
63 63
                                                                                     self::STREAMER_TYPE     => "SyncTaskRecurrence",
64 64
                                                                                     self::STREAMER_RONOTIFY => true),
65 65
 
66
-                    SYNC_POOMTASKS_REGENERATE                           => array (  self::STREAMER_VAR      => "regenerate",
66
+                    SYNC_POOMTASKS_REGENERATE                           => array(self::STREAMER_VAR      => "regenerate",
67 67
                                                                                     self::STREAMER_RONOTIFY => true),
68
-                    SYNC_POOMTASKS_DEADOCCUR                            => array (  self::STREAMER_VAR      => "deadoccur",
68
+                    SYNC_POOMTASKS_DEADOCCUR                            => array(self::STREAMER_VAR      => "deadoccur",
69 69
                                                                                     self::STREAMER_RONOTIFY => true),
70
-                    SYNC_POOMTASKS_REMINDERSET                          => array (  self::STREAMER_VAR      => "reminderset",
71
-                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETZERO,
72
-                                                                                                                        self::STREAMER_CHECK_ZEROORONE      => self::STREAMER_CHECK_SETZERO ),
70
+                    SYNC_POOMTASKS_REMINDERSET                          => array(self::STREAMER_VAR      => "reminderset",
71
+                                                                                    self::STREAMER_CHECKS   => array(self::STREAMER_CHECK_REQUIRED       => self::STREAMER_CHECK_SETZERO,
72
+                                                                                                                        self::STREAMER_CHECK_ZEROORONE      => self::STREAMER_CHECK_SETZERO),
73 73
                                                                                     self::STREAMER_RONOTIFY => true),
74 74
 
75
-                    SYNC_POOMTASKS_REMINDERTIME                         => array (  self::STREAMER_VAR      => "remindertime",
75
+                    SYNC_POOMTASKS_REMINDERTIME                         => array(self::STREAMER_VAR      => "remindertime",
76 76
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
77 77
                                                                                     self::STREAMER_RONOTIFY => true),
78 78
 
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
                     // 1 = Personal
82 82
                     // 2 = Private
83 83
                     // 3 = Confident
84
-                    SYNC_POOMTASKS_SENSITIVITY                          => array (  self::STREAMER_VAR      => "sensitivity",
85
-                                                                                    self::STREAMER_CHECKS   => array(   self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) ),
84
+                    SYNC_POOMTASKS_SENSITIVITY                          => array(self::STREAMER_VAR      => "sensitivity",
85
+                                                                                    self::STREAMER_CHECKS   => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 2, 3)),
86 86
                                                                                     self::STREAMER_RONOTIFY => true),
87 87
 
88
-                    SYNC_POOMTASKS_STARTDATE                            => array (  self::STREAMER_VAR      => "startdate",
88
+                    SYNC_POOMTASKS_STARTDATE                            => array(self::STREAMER_VAR      => "startdate",
89 89
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
90 90
                                                                                     self::STREAMER_RONOTIFY => true),
91 91
 
92
-                    SYNC_POOMTASKS_UTCSTARTDATE                         => array (  self::STREAMER_VAR      => "utcstartdate",
92
+                    SYNC_POOMTASKS_UTCSTARTDATE                         => array(self::STREAMER_VAR      => "utcstartdate",
93 93
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
94 94
                                                                                     self::STREAMER_RONOTIFY => true),
95 95
 
96
-                    SYNC_POOMTASKS_SUBJECT                              => array (  self::STREAMER_VAR      => "subject",
96
+                    SYNC_POOMTASKS_SUBJECT                              => array(self::STREAMER_VAR      => "subject",
97 97
                                                                                     self::STREAMER_RONOTIFY => true),
98
-                    SYNC_POOMTASKS_RTF                                  => array (  self::STREAMER_VAR      => "rtf"),
99
-                    SYNC_POOMTASKS_CATEGORIES                           => array (  self::STREAMER_VAR      => "categories",
98
+                    SYNC_POOMTASKS_RTF                                  => array(self::STREAMER_VAR      => "rtf"),
99
+                    SYNC_POOMTASKS_CATEGORIES                           => array(self::STREAMER_VAR      => "categories",
100 100
                                                                                     self::STREAMER_ARRAY    => SYNC_POOMTASKS_CATEGORY,
101 101
                                                                                     self::STREAMER_RONOTIFY => true),
102 102
                 );
103 103
 
104 104
             if (Request::GetProtocolVersion() >= 12.0) {
105
-            $mapping[SYNC_AIRSYNCBASE_BODY]                             = array (   self::STREAMER_VAR      => "asbody",
105
+            $mapping[SYNC_AIRSYNCBASE_BODY] = array(self::STREAMER_VAR      => "asbody",
106 106
                                                                                     self::STREAMER_TYPE     => "SyncBaseBody",
107 107
                                                                                     self::STREAMER_RONOTIFY => true);
108 108
 
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
             return false;
136 136
 
137 137
         if (isset($this->startdate) && isset($this->duedate) && $this->duedate < $this->startdate) {
138
-            ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'startdate' is HIGHER than 'duedate'. Check failed!", get_class($this) ));
138
+            ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'startdate' is HIGHER than 'duedate'. Check failed!", get_class($this)));
139 139
             return false;
140 140
         }
141 141
 
142 142
         if (isset($this->utcstartdate) && isset($this->utcduedate) && $this->utcduedate < $this->utcstartdate) {
143
-            ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'utcstartdate' is HIGHER than 'utcduedate'. Check failed!", get_class($this) ));
143
+            ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'utcstartdate' is HIGHER than 'utcduedate'. Check failed!", get_class($this)));
144 144
             return false;
145 145
         }
146 146
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -128,11 +128,13 @@
 block discarded – undo
128 128
         $ret = parent::Check($logAsDebug);
129 129
 
130 130
         // semantic checks general "turn off switch"
131
-        if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false)
132
-            return $ret;
131
+        if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) {
132
+                    return $ret;
133
+        }
133 134
 
134
-        if (!$ret)
135
-            return false;
135
+        if (!$ret) {
136
+                    return false;
137
+        }
136 138
 
137 139
         if (isset($this->startdate) && isset($this->duedate) && $this->duedate < $this->startdate) {
138 140
             ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'startdate' is HIGHER than 'duedate'. Check failed!", get_class($this) ));
Please login to merge, or discard this patch.
lib/syncobjects/syncresolverecipient.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@
 block discarded – undo
30 30
 
31 31
         if (Request::GetProtocolVersion() >= 14.0) {
32 32
             $mapping[SYNC_RESOLVERECIPIENTS_AVAILABILITY]   = array (  self::STREAMER_VAR      => "availability",
33
-                                                                       self::STREAMER_TYPE     => "SyncResolveRecipientsAvailability");
33
+                                                                        self::STREAMER_TYPE     => "SyncResolveRecipientsAvailability");
34 34
         }
35 35
 
36 36
         if (Request::GetProtocolVersion() >= 14.1) {
37 37
             $mapping[SYNC_RESOLVERECIPIENTS_PICTURE]        = array (  self::STREAMER_VAR      => "picture",
38
-                                                                       self::STREAMER_TYPE     => "SyncResolveRecipientsPicture");
38
+                                                                        self::STREAMER_TYPE     => "SyncResolveRecipientsPicture");
39 39
         }
40 40
 
41 41
         parent::__construct($mapping);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@
 block discarded – undo
19 19
     public $id;
20 20
 
21 21
     public function __construct() {
22
-        $mapping = array (
23
-            SYNC_RESOLVERECIPIENTS_TYPE                     => array (  self::STREAMER_VAR      => "type"),
24
-            SYNC_RESOLVERECIPIENTS_DISPLAYNAME              => array (  self::STREAMER_VAR      => "displayname"),
25
-            SYNC_RESOLVERECIPIENTS_EMAILADDRESS             => array (  self::STREAMER_VAR      => "emailaddress"),
22
+        $mapping = array(
23
+            SYNC_RESOLVERECIPIENTS_TYPE                     => array(self::STREAMER_VAR      => "type"),
24
+            SYNC_RESOLVERECIPIENTS_DISPLAYNAME              => array(self::STREAMER_VAR      => "displayname"),
25
+            SYNC_RESOLVERECIPIENTS_EMAILADDRESS             => array(self::STREAMER_VAR      => "emailaddress"),
26 26
 
27
-            SYNC_RESOLVERECIPIENTS_CERTIFICATES             => array (  self::STREAMER_VAR      => "certificates",
27
+            SYNC_RESOLVERECIPIENTS_CERTIFICATES             => array(self::STREAMER_VAR      => "certificates",
28 28
                                                                         self::STREAMER_TYPE     => "SyncResolveRecipientsCertificates")
29 29
         );
30 30
 
31 31
         if (Request::GetProtocolVersion() >= 14.0) {
32
-            $mapping[SYNC_RESOLVERECIPIENTS_AVAILABILITY]   = array (  self::STREAMER_VAR      => "availability",
32
+            $mapping[SYNC_RESOLVERECIPIENTS_AVAILABILITY] = array(self::STREAMER_VAR      => "availability",
33 33
                                                                        self::STREAMER_TYPE     => "SyncResolveRecipientsAvailability");
34 34
         }
35 35
 
36 36
         if (Request::GetProtocolVersion() >= 14.1) {
37
-            $mapping[SYNC_RESOLVERECIPIENTS_PICTURE]        = array (  self::STREAMER_VAR      => "picture",
37
+            $mapping[SYNC_RESOLVERECIPIENTS_PICTURE] = array(self::STREAMER_VAR      => "picture",
38 38
                                                                        self::STREAMER_TYPE     => "SyncResolveRecipientsPicture");
39 39
         }
40 40
 
Please login to merge, or discard this patch.
lib/syncobjects/syncmailflags.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -27,47 +27,47 @@
 block discarded – undo
27 27
 
28 28
     function __construct() {
29 29
         $mapping = array(
30
-                    SYNC_POOMTASKS_SUBJECT                              => array (  self::STREAMER_VAR      => "subject",
30
+                    SYNC_POOMTASKS_SUBJECT                              => array(self::STREAMER_VAR      => "subject",
31 31
                                                                                     self::STREAMER_RONOTIFY => true),
32
-                    SYNC_POOMMAIL_FLAGSTATUS                            => array (  self::STREAMER_VAR      => "flagstatus",
32
+                    SYNC_POOMMAIL_FLAGSTATUS                            => array(self::STREAMER_VAR      => "flagstatus",
33 33
                                                                                     self::STREAMER_RONOTIFY => true),
34
-                    SYNC_POOMMAIL_FLAGTYPE                              => array (  self::STREAMER_VAR      => "flagtype",
34
+                    SYNC_POOMMAIL_FLAGTYPE                              => array(self::STREAMER_VAR      => "flagtype",
35 35
                                                                                     self::STREAMER_RONOTIFY => true),
36
-                    SYNC_POOMTASKS_DATECOMPLETED                        => array (  self::STREAMER_VAR      => "datecompleted",
36
+                    SYNC_POOMTASKS_DATECOMPLETED                        => array(self::STREAMER_VAR      => "datecompleted",
37 37
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
38 38
                                                                                     self::STREAMER_RONOTIFY => true),
39 39
 
40
-                    SYNC_POOMMAIL_COMPLETETIME                          => array (  self::STREAMER_VAR      => "completetime",
40
+                    SYNC_POOMMAIL_COMPLETETIME                          => array(self::STREAMER_VAR      => "completetime",
41 41
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
42 42
                                                                                     self::STREAMER_RONOTIFY => true),
43 43
 
44
-                    SYNC_POOMTASKS_STARTDATE                            => array (  self::STREAMER_VAR      => "startdate",
44
+                    SYNC_POOMTASKS_STARTDATE                            => array(self::STREAMER_VAR      => "startdate",
45 45
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
46 46
                                                                                     self::STREAMER_RONOTIFY => true),
47 47
 
48
-                    SYNC_POOMTASKS_DUEDATE                              => array (  self::STREAMER_VAR      => "duedate",
48
+                    SYNC_POOMTASKS_DUEDATE                              => array(self::STREAMER_VAR      => "duedate",
49 49
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
50 50
                                                                                     self::STREAMER_RONOTIFY => true),
51 51
 
52
-                    SYNC_POOMTASKS_UTCSTARTDATE                         => array (  self::STREAMER_VAR      => "utcstartdate",
52
+                    SYNC_POOMTASKS_UTCSTARTDATE                         => array(self::STREAMER_VAR      => "utcstartdate",
53 53
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
54 54
                                                                                     self::STREAMER_RONOTIFY => true),
55 55
 
56
-                    SYNC_POOMTASKS_UTCDUEDATE                           => array (  self::STREAMER_VAR      => "utcduedate",
56
+                    SYNC_POOMTASKS_UTCDUEDATE                           => array(self::STREAMER_VAR      => "utcduedate",
57 57
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
58 58
                                                                                     self::STREAMER_RONOTIFY => true),
59 59
 
60
-                    SYNC_POOMTASKS_REMINDERSET                          => array (  self::STREAMER_VAR      => "reminderset",
60
+                    SYNC_POOMTASKS_REMINDERSET                          => array(self::STREAMER_VAR      => "reminderset",
61 61
                                                                                     self::STREAMER_RONOTIFY => true),
62
-                    SYNC_POOMTASKS_REMINDERTIME                         => array (  self::STREAMER_VAR      => "remindertime",
62
+                    SYNC_POOMTASKS_REMINDERTIME                         => array(self::STREAMER_VAR      => "remindertime",
63 63
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
64 64
                                                                                     self::STREAMER_RONOTIFY => true),
65 65
 
66
-                    SYNC_POOMTASKS_ORDINALDATE                          => array (  self::STREAMER_VAR      => "ordinaldate",
66
+                    SYNC_POOMTASKS_ORDINALDATE                          => array(self::STREAMER_VAR      => "ordinaldate",
67 67
                                                                                     self::STREAMER_TYPE     => self::STREAMER_TYPE_DATE_DASHES,
68 68
                                                                                     self::STREAMER_RONOTIFY => true),
69 69
 
70
-                    SYNC_POOMTASKS_SUBORDINALDATE                       => array (  self::STREAMER_VAR      => "subordinaldate",
70
+                    SYNC_POOMTASKS_SUBORDINALDATE                       => array(self::STREAMER_VAR      => "subordinaldate",
71 71
                                                                                     self::STREAMER_RONOTIFY => true),
72 72
         );
73 73
 
Please login to merge, or discard this patch.
lib/syncobjects/syncobject.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     const STREAMER_CHECK_CMPLOWER = 13;
23 23
     const STREAMER_CHECK_CMPHIGHER = 14;
24 24
     const STREAMER_CHECK_LENGTHMAX = 15;
25
-    const STREAMER_CHECK_EMAIL   = 16;
25
+    const STREAMER_CHECK_EMAIL = 16;
26 26
 
27 27
     protected $unsetVars;
28 28
     protected $supportsPrivateStripping;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             return false;
86 86
 
87 87
         // check objecttype
88
-        if (! ($odo instanceof SyncObject)) {
88
+        if (!($odo instanceof SyncObject)) {
89 89
             ZLog::Write(LOGLEVEL_DEBUG, "SyncObject->equals() the target object is not a SyncObject");
90 90
             return false;
91 91
         }
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
             }
115 115
             else {
116 116
                 if (isset($this->$val) && isset($odo->$val)) {
117
-                    if ($strictTypeCompare){
118
-                        if ($this->$val !== $odo->$val){
117
+                    if ($strictTypeCompare) {
118
+                        if ($this->$val !== $odo->$val) {
119 119
                             ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() false on field '%s': '%s' != '%s' using strictTypeCompare", $val, Utils::PrintAsString($this->$val), Utils::PrintAsString($odo->$val)));
120 120
                             return false;
121 121
                         }
122 122
                     } else {
123
-                        if ($this->$val != $odo->$val){
123
+                        if ($this->$val != $odo->$val) {
124 124
                             ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() false on field '%s': '%s' != '%s'", $val, Utils::PrintAsString($this->$val), Utils::PrintAsString($odo->$val)));
125 125
                             return false;
126 126
                         }
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
      * @return String
146 146
      */
147 147
     public function __toString() {
148
-        $str = get_class($this) . " (\n";
148
+        $str = get_class($this)." (\n";
149 149
 
150 150
         $streamerVars = array();
151 151
         foreach ($this->mapping as $k=>$v)
152
-            $streamerVars[$v[self::STREAMER_VAR]] = (isset($v[self::STREAMER_TYPE]))?$v[self::STREAMER_TYPE]:false;
152
+            $streamerVars[$v[self::STREAMER_VAR]] = (isset($v[self::STREAMER_TYPE])) ? $v[self::STREAMER_TYPE] : false;
153 153
 
154 154
         foreach (get_object_vars($this) as $k=>$v) {
155 155
             if ($k == "mapping") continue;
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
 
162 162
             // self::STREAMER_ARRAY ?
163 163
             if (is_array($v)) {
164
-                $str .= "\t". $strV . $k ."(Array) size: " . count($v) ."\n";
165
-                foreach ($v as $value) $str .= "\t\t". Utils::PrintAsString($value) ."\n";
164
+                $str .= "\t".$strV.$k."(Array) size: ".count($v)."\n";
165
+                foreach ($v as $value) $str .= "\t\t".Utils::PrintAsString($value)."\n";
166 166
             }
167 167
             else if ($v instanceof SyncObject) {
168
-                $str .= "\t". $strV .$k ." => ". str_replace("\n", "\n\t\t\t", $v->__toString()) . "\n";
168
+                $str .= "\t".$strV.$k." => ".str_replace("\n", "\n\t\t\t", $v->__toString())."\n";
169 169
             }
170 170
             else
171
-                $str .= "\t". $strV .$k ." => " . (isset($this->$k)? Utils::PrintAsString($this->$k) :"null") . "\n";
171
+                $str .= "\t".$strV.$k." => ".(isset($this->$k) ? Utils::PrintAsString($this->$k) : "null")."\n";
172 172
         }
173 173
         $str .= ")";
174 174
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             // check sub-objects recursively
248 248
             if (isset($v[self::STREAMER_TYPE]) && isset($this->{$v[self::STREAMER_VAR]})) {
249 249
                 if ($this->{$v[self::STREAMER_VAR]} instanceof SyncObject) {
250
-                    if (! $this->{$v[self::STREAMER_VAR]}->Check($logAsDebug))
250
+                    if (!$this->{$v[self::STREAMER_VAR]}->Check($logAsDebug))
251 251
                         return false;
252 252
                 }
253 253
                 else if (is_array($this->{$v[self::STREAMER_VAR]})) {
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             if (isset($v[self::STREAMER_CHECKS])) {
261 261
                 foreach ($v[self::STREAMER_CHECKS] as $rule => $condition) {
262 262
                     // check REQUIRED settings
263
-                    if ($rule === self::STREAMER_CHECK_REQUIRED && (!isset($this->{$v[self::STREAMER_VAR]}) || $this->{$v[self::STREAMER_VAR]} === '' ) ) {
263
+                    if ($rule === self::STREAMER_CHECK_REQUIRED && (!isset($this->{$v[self::STREAMER_VAR]}) || $this->{$v[self::STREAMER_VAR]} === '')) {
264 264
                         // parameter is not set but ..
265 265
                         // requested to set to 0
266 266
                         if ($condition === self::STREAMER_CHECK_SETZERO) {
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                     // check STREAMER_CHECK_ZEROORONE
302 302
                     if ($rule === self::STREAMER_CHECK_ZEROORONE && isset($this->{$v[self::STREAMER_VAR]})) {
303 303
                         if ($this->{$v[self::STREAMER_VAR]} != 0 && $this->{$v[self::STREAMER_VAR]} != 1) {
304
-                            $newval = $condition === self::STREAMER_CHECK_SETZERO ? 0:1;
304
+                            $newval = $condition === self::STREAMER_CHECK_SETZERO ? 0 : 1;
305 305
                             $this->{$v[self::STREAMER_VAR]} = $newval;
306 306
                             ZLog::Write($defaultLogLevel, sprintf("SyncObject->Check(): Fixed object from type %s: parameter '%s' is set to '%s' as it was not 0 or 1", $objClass, $v[self::STREAMER_VAR], $newval));
307 307
                         }
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
                                 ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter '%s' can not be compared, as the comparable is not set. Check failed!", $objClass, $v[self::STREAMER_VAR]));
341 341
                                 return false;
342 342
                             }
343
-                            if ( ($rule == self::STREAMER_CHECK_CMPHIGHER && $this->{$v[self::STREAMER_VAR]} < $cmp) ||
344
-                                 ($rule == self::STREAMER_CHECK_CMPLOWER  && $this->{$v[self::STREAMER_VAR]} > $cmp)
343
+                            if (($rule == self::STREAMER_CHECK_CMPHIGHER && $this->{$v[self::STREAMER_VAR]} < $cmp) ||
344
+                                 ($rule == self::STREAMER_CHECK_CMPLOWER && $this->{$v[self::STREAMER_VAR]} > $cmp)
345 345
                                 ) {
346 346
 
347 347
                                 ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter '%s' is %s than '%s'. Check failed!",
348 348
                                                                     $objClass,
349 349
                                                                     $v[self::STREAMER_VAR],
350
-                                                                    (($rule === self::STREAMER_CHECK_CMPHIGHER)?'LOWER':'HIGHER'),
351
-                                                                    ((isset($cmpPar)?$cmpPar:$condition))  ));
350
+                                                                    (($rule === self::STREAMER_CHECK_CMPHIGHER) ? 'LOWER' : 'HIGHER'),
351
+                                                                    ((isset($cmpPar) ? $cmpPar : $condition))));
352 352
                                 return false;
353 353
                             }
354 354
                         }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                     // if $condition is false then the check really fails. Otherwise invalid emails are removed.
377 377
                     // if nothing is left (all emails were false), the parameter is set to condition
378 378
                     if ($rule === self::STREAMER_CHECK_EMAIL && isset($this->{$v[self::STREAMER_VAR]})) {
379
-                        if ($condition === false && ( (is_array($this->{$v[self::STREAMER_VAR]}) && empty($this->{$v[self::STREAMER_VAR]})) || strlen($this->{$v[self::STREAMER_VAR]}) == 0) )
379
+                        if ($condition === false && ((is_array($this->{$v[self::STREAMER_VAR]}) && empty($this->{$v[self::STREAMER_VAR]})) || strlen($this->{$v[self::STREAMER_VAR]}) == 0))
380 380
                             continue;
381 381
 
382 382
                         $as_array = false;
@@ -386,12 +386,12 @@  discard block
 block discarded – undo
386 386
                             $as_array = true;
387 387
                         }
388 388
                         else {
389
-                            $mails = array( $this->{$v[self::STREAMER_VAR]} );
389
+                            $mails = array($this->{$v[self::STREAMER_VAR]} );
390 390
                         }
391 391
 
392 392
                         $output = array();
393 393
                         foreach ($mails as $mail) {
394
-                            if (! Utils::CheckEmail($mail)) {
394
+                            if (!Utils::CheckEmail($mail)) {
395 395
                                 ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): object from type %s: parameter '%s' contains an invalid email address '%s'. Address is removed.", $objClass, $v[self::STREAMER_VAR], $mail));
396 396
                             }
397 397
                             else
Please login to merge, or discard this patch.
Braces   +62 added lines, -56 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@  discard block
 block discarded – undo
49 49
             if (defined('UNSET_UNDEFINED_PROPERTIES') && UNSET_UNDEFINED_PROPERTIES && ($this instanceof SyncContact || $this instanceof SyncAppointment || $this instanceof SyncTask)) {
50 50
                 ZLog::Write(LOGLEVEL_INFO, sprintf("%s->emptySupported(): no supported list available, emptying all not set parameters", get_class($this)));
51 51
                 $supportedFields = array_keys($this->mapping);
52
-            }
53
-            else {
52
+            } else {
54 53
                 return false;
55 54
             }
56 55
         }
@@ -62,8 +61,9 @@  discard block
 block discarded – undo
62 61
             }
63 62
             $var = $this->mapping[$field][self::STREAMER_VAR];
64 63
             // add var to $this->unsetVars if $var is not set
65
-            if (!isset($this->$var))
66
-                $this->unsetVars[] = $var;
64
+            if (!isset($this->$var)) {
65
+                            $this->unsetVars[] = $var;
66
+            }
67 67
         }
68 68
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("Supported variables to be unset: %s", implode(',', $this->unsetVars)));
69 69
         return true;
@@ -81,8 +81,9 @@  discard block
 block discarded – undo
81 81
      * @return boolean
82 82
      */
83 83
     public function equals($odo, $log = false, $strictTypeCompare = false) {
84
-        if ($odo === false)
85
-            return false;
84
+        if ($odo === false) {
85
+                    return false;
86
+        }
86 87
 
87 88
         // check objecttype
88 89
         if (! ($odo instanceof SyncObject)) {
@@ -99,20 +100,17 @@  discard block
 block discarded – undo
99 100
                 if (!isset($this->$val) && !isset($odo->$val)) {
100 101
                     ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() array '%s' is NOT SET in either object", $val));
101 102
                     continue;
102
-                }
103
-                elseif (is_array($this->$val) && is_array($odo->$val)) {
103
+                } elseif (is_array($this->$val) && is_array($odo->$val)) {
104 104
                     // if both arrays exist then seek for differences in the arrays
105 105
                     if (count(array_diff($this->$val, $odo->$val)) + count(array_diff($odo->$val, $this->$val)) > 0) {
106 106
                         ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() items in array '%s' differ", $val));
107 107
                         return false;
108 108
                     }
109
-                }
110
-                else {
109
+                } else {
111 110
                     ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() array '%s' is set in one but not the other object", $val));
112 111
                     return false;
113 112
                 }
114
-            }
115
-            else {
113
+            } else {
116 114
                 if (isset($this->$val) && isset($odo->$val)) {
117 115
                     if ($strictTypeCompare){
118 116
                         if ($this->$val !== $odo->$val){
@@ -125,11 +123,9 @@  discard block
 block discarded – undo
125 123
                             return false;
126 124
                         }
127 125
                     }
128
-                }
129
-                else if (!isset($this->$val) && !isset($odo->$val)) {
126
+                } else if (!isset($this->$val) && !isset($odo->$val)) {
130 127
                     continue;
131
-                }
132
-                else {
128
+                } else {
133 129
                     ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncObject->equals() false because field '%s' is only defined at one obj: '%s' != '%s'", $val, Utils::PrintAsString(isset($this->$val)), Utils::PrintAsString(isset($odo->$val))));
134 130
                     return false;
135 131
                 }
@@ -148,27 +144,32 @@  discard block
 block discarded – undo
148 144
         $str = get_class($this) . " (\n";
149 145
 
150 146
         $streamerVars = array();
151
-        foreach ($this->mapping as $k=>$v)
152
-            $streamerVars[$v[self::STREAMER_VAR]] = (isset($v[self::STREAMER_TYPE]))?$v[self::STREAMER_TYPE]:false;
147
+        foreach ($this->mapping as $k=>$v) {
148
+                    $streamerVars[$v[self::STREAMER_VAR]] = (isset($v[self::STREAMER_TYPE]))?$v[self::STREAMER_TYPE]:false;
149
+        }
153 150
 
154 151
         foreach (get_object_vars($this) as $k=>$v) {
155
-            if ($k == "mapping") continue;
152
+            if ($k == "mapping") {
153
+                continue;
154
+            }
156 155
 
157
-            if (array_key_exists($k, $streamerVars))
158
-                $strV = "(S) ";
159
-            else
160
-                $strV = "";
156
+            if (array_key_exists($k, $streamerVars)) {
157
+                            $strV = "(S) ";
158
+            } else {
159
+                            $strV = "";
160
+            }
161 161
 
162 162
             // self::STREAMER_ARRAY ?
163 163
             if (is_array($v)) {
164 164
                 $str .= "\t". $strV . $k ."(Array) size: " . count($v) ."\n";
165
-                foreach ($v as $value) $str .= "\t\t". Utils::PrintAsString($value) ."\n";
166
-            }
167
-            else if ($v instanceof SyncObject) {
165
+                foreach ($v as $value) {
166
+                    $str .= "\t\t". Utils::PrintAsString($value) ."\n";
167
+                }
168
+            } else if ($v instanceof SyncObject) {
168 169
                 $str .= "\t". $strV .$k ." => ". str_replace("\n", "\n\t\t\t", $v->__toString()) . "\n";
170
+            } else {
171
+                            $str .= "\t". $strV .$k ." => " . (isset($this->$k)? Utils::PrintAsString($this->$k) :"null") . "\n";
169 172
             }
170
-            else
171
-                $str .= "\t". $strV .$k ." => " . (isset($this->$k)? Utils::PrintAsString($this->$k) :"null") . "\n";
172 173
         }
173 174
         $str .= ")";
174 175
 
@@ -238,8 +239,9 @@  discard block
 block discarded – undo
238 239
         $defaultLogLevel = LOGLEVEL_WARN;
239 240
 
240 241
         // in some cases non-false checks should not provoke a WARN log but only a DEBUG log
241
-        if ($logAsDebug)
242
-            $defaultLogLevel = LOGLEVEL_DEBUG;
242
+        if ($logAsDebug) {
243
+                    $defaultLogLevel = LOGLEVEL_DEBUG;
244
+        }
243 245
 
244 246
         $objClass = get_class($this);
245 247
         foreach ($this->mapping as $k=>$v) {
@@ -247,13 +249,14 @@  discard block
 block discarded – undo
247 249
             // check sub-objects recursively
248 250
             if (isset($v[self::STREAMER_TYPE]) && isset($this->{$v[self::STREAMER_VAR]})) {
249 251
                 if ($this->{$v[self::STREAMER_VAR]} instanceof SyncObject) {
250
-                    if (! $this->{$v[self::STREAMER_VAR]}->Check($logAsDebug))
251
-                        return false;
252
-                }
253
-                else if (is_array($this->{$v[self::STREAMER_VAR]})) {
254
-                    foreach ($this->{$v[self::STREAMER_VAR]} as $subobj)
255
-                        if ($subobj instanceof SyncObject && !$subobj->Check($logAsDebug))
252
+                    if (! $this->{$v[self::STREAMER_VAR]}->Check($logAsDebug)) {
253
+                                            return false;
254
+                    }
255
+                } else if (is_array($this->{$v[self::STREAMER_VAR]})) {
256
+                    foreach ($this->{$v[self::STREAMER_VAR]} as $subobj) {
257
+                                            if ($subobj instanceof SyncObject && !$subobj->Check($logAsDebug))
256 258
                             return false;
259
+                    }
257 260
                 }
258 261
             }
259 262
 
@@ -329,11 +332,11 @@  discard block
 block discarded – undo
329 332
                             else if (!isset($this->mapping[$condition])) {
330 333
                                 ZLog::Write(LOGLEVEL_ERROR, sprintf("SyncObject->Check(): Can not compare parameter '%s' against the other value '%s' as it is not defined object from type %s. Please report this! Check skipped!", $objClass, $v[self::STREAMER_VAR], $condition));
331 334
                                 continue;
332
-                            }
333
-                            else {
335
+                            } else {
334 336
                                 $cmpPar = $this->mapping[$condition][self::STREAMER_VAR];
335
-                                if (isset($this->$cmpPar))
336
-                                    $cmp = $this->$cmpPar;
337
+                                if (isset($this->$cmpPar)) {
338
+                                                                    $cmp = $this->$cmpPar;
339
+                                }
337 340
                             }
338 341
 
339 342
                             if ($cmp === false) {
@@ -361,9 +364,9 @@  discard block
 block discarded – undo
361 364
                         if (is_array($this->{$v[self::STREAMER_VAR]})) {
362 365
                             // implosion takes 2bytes, so we just assume ", " here
363 366
                             $chkstr = implode(", ", $this->{$v[self::STREAMER_VAR]});
367
+                        } else {
368
+                                                    $chkstr = $this->{$v[self::STREAMER_VAR]};
364 369
                         }
365
-                        else
366
-                            $chkstr = $this->{$v[self::STREAMER_VAR]};
367 370
 
368 371
                         if (strlen($chkstr) > $condition) {
369 372
                             ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): object from type %s: parameter '%s' is longer than %d. Check failed", $objClass, $v[self::STREAMER_VAR], $condition));
@@ -376,16 +379,16 @@  discard block
 block discarded – undo
376 379
                     // if $condition is false then the check really fails. Otherwise invalid emails are removed.
377 380
                     // if nothing is left (all emails were false), the parameter is set to condition
378 381
                     if ($rule === self::STREAMER_CHECK_EMAIL && isset($this->{$v[self::STREAMER_VAR]})) {
379
-                        if ($condition === false && ( (is_array($this->{$v[self::STREAMER_VAR]}) && empty($this->{$v[self::STREAMER_VAR]})) || strlen($this->{$v[self::STREAMER_VAR]}) == 0) )
380
-                            continue;
382
+                        if ($condition === false && ( (is_array($this->{$v[self::STREAMER_VAR]}) && empty($this->{$v[self::STREAMER_VAR]})) || strlen($this->{$v[self::STREAMER_VAR]}) == 0) ) {
383
+                                                    continue;
384
+                        }
381 385
 
382 386
                         $as_array = false;
383 387
 
384 388
                         if (is_array($this->{$v[self::STREAMER_VAR]})) {
385 389
                             $mails = $this->{$v[self::STREAMER_VAR]};
386 390
                             $as_array = true;
387
-                        }
388
-                        else {
391
+                        } else {
389 392
                             $mails = array( $this->{$v[self::STREAMER_VAR]} );
390 393
                         }
391 394
 
@@ -393,23 +396,26 @@  discard block
 block discarded – undo
393 396
                         foreach ($mails as $mail) {
394 397
                             if (! Utils::CheckEmail($mail)) {
395 398
                                 ZLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): object from type %s: parameter '%s' contains an invalid email address '%s'. Address is removed.", $objClass, $v[self::STREAMER_VAR], $mail));
399
+                            } else {
400
+                                                            $output[] = $mail;
396 401
                             }
397
-                            else
398
-                                $output[] = $mail;
399 402
                         }
400 403
                         if (count($mails) != count($output)) {
401
-                            if ($condition === false)
402
-                                return false;
404
+                            if ($condition === false) {
405
+                                                            return false;
406
+                            }
403 407
 
404 408
                             // nothing left, use $condition as new value
405
-                            if (count($output) == 0)
406
-                                $output[] = $condition;
409
+                            if (count($output) == 0) {
410
+                                                            $output[] = $condition;
411
+                            }
407 412
 
408 413
                             // if we are allowed to rewrite the attribute, we do that
409
-                            if ($as_array)
410
-                                $this->{$v[self::STREAMER_VAR]} = $output;
411
-                            else
412
-                                $this->{$v[self::STREAMER_VAR]} = $output[0];
414
+                            if ($as_array) {
415
+                                                            $this->{$v[self::STREAMER_VAR]} = $output;
416
+                            } else {
417
+                                                            $this->{$v[self::STREAMER_VAR]} = $output[0];
418
+                            }
413 419
                         }
414 420
                     }// end STREAMER_CHECK_EMAIL
415 421
 
Please login to merge, or discard this patch.
lib/syncobjects/syncresolverecipientspicture.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
23 23
             $mapping[SYNC_RESOLVERECIPIENTS_MAXPICTURES]    = array (  self::STREAMER_VAR      => "maxpictures");
24 24
             $mapping[SYNC_RESOLVERECIPIENTS_STATUS]         = array (  self::STREAMER_VAR      => "status");
25 25
             $mapping[SYNC_RESOLVERECIPIENTS_DATA]           = array (  self::STREAMER_VAR      => "data",
26
-                                                                       self::STREAMER_TYPE     => self::STREAMER_TYPE_STREAM_ASBASE64,
27
-                                                                     );
26
+                                                                        self::STREAMER_TYPE     => self::STREAMER_TYPE_STREAM_ASBASE64,
27
+                                                                        );
28 28
         }
29 29
 
30 30
         parent::__construct($mapping);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@
 block discarded – undo
16 16
     public $data;
17 17
 
18 18
     public function __construct() {
19
-        $mapping = array ();
19
+        $mapping = array();
20 20
 
21 21
         if (Request::GetProtocolVersion() >= 14.1) {
22
-            $mapping[SYNC_RESOLVERECIPIENTS_MAXSIZE]        = array (  self::STREAMER_VAR      => "maxsize");
23
-            $mapping[SYNC_RESOLVERECIPIENTS_MAXPICTURES]    = array (  self::STREAMER_VAR      => "maxpictures");
24
-            $mapping[SYNC_RESOLVERECIPIENTS_STATUS]         = array (  self::STREAMER_VAR      => "status");
25
-            $mapping[SYNC_RESOLVERECIPIENTS_DATA]           = array (  self::STREAMER_VAR      => "data",
22
+            $mapping[SYNC_RESOLVERECIPIENTS_MAXSIZE]        = array(self::STREAMER_VAR      => "maxsize");
23
+            $mapping[SYNC_RESOLVERECIPIENTS_MAXPICTURES]    = array(self::STREAMER_VAR      => "maxpictures");
24
+            $mapping[SYNC_RESOLVERECIPIENTS_STATUS]         = array(self::STREAMER_VAR      => "status");
25
+            $mapping[SYNC_RESOLVERECIPIENTS_DATA]           = array(self::STREAMER_VAR      => "data",
26 26
                                                                        self::STREAMER_TYPE     => self::STREAMER_TYPE_STREAM_ASBASE64,
27 27
                                                                      );
28 28
         }
Please login to merge, or discard this patch.