Completed
Push — 16.1 ( 7ccc73...046888 )
by Nathan
64:46 queued 51:15
created
api/src/WebDAV/Tools/_parse_propfind.php 1 patch
Braces   +42 added lines, -16 removed lines patch added patch discarded remove patch
@@ -127,7 +127,8 @@  discard block
 block discarded – undo
127 127
 
128 128
         // open input stream
129 129
         $f_in = fopen($path, "r");
130
-        if (!$f_in) {
130
+        if (!$f_in)
131
+        {
131 132
             $this->success = false;
132 133
             return;
133 134
         }
@@ -149,17 +150,23 @@  discard block
 block discarded – undo
149 150
                               XML_OPTION_CASE_FOLDING, false);
150 151
 
151 152
         // parse input
152
-        while ($this->success && !feof($f_in)) {
153
+        while ($this->success && !feof($f_in))
154
+        {
153 155
             $line = fgets($f_in);
154
-            if ($store_request) $this->request .= $line;
155
-            if (is_string($line)) {
156
+            if ($store_request)
157
+            {
158
+            	$this->request .= $line;
159
+            }
160
+            if (is_string($line))
161
+            {
156 162
                 $had_input = true;
157 163
                 $this->success &= xml_parse($xml_parser, $line, false);
158 164
             }
159 165
         }
160 166
 
161 167
         // finish parsing
162
-        if ($had_input) {
168
+        if ($had_input)
169
+        {
163 170
             $this->success &= xml_parse($xml_parser, "", true);
164 171
         }
165 172
 
@@ -170,7 +177,11 @@  discard block
 block discarded – undo
170 177
         fclose($f_in);
171 178
 
172 179
         // if no input was parsed it was a request
173
-        if(!count($this->props)) $this->props = "all"; // default
180
+        if(!count($this->props))
181
+        {
182
+        	$this->props = "all";
183
+        }
184
+        // default
174 185
     }
175 186
 
176 187
 
@@ -185,21 +196,28 @@  discard block
 block discarded – undo
185 196
     function _startElement($parser, $name, $attrs)
186 197
     {
187 198
         // name space handling
188
-        if (strstr($name, " ")) {
199
+        if (strstr($name, " "))
200
+        {
189 201
             list($ns, $tag) = explode(" ", $name);
190 202
             if ($ns == "")
191
-                $this->success = false;
192
-        } else {
203
+            {
204
+                            $this->success = false;
205
+            }
206
+        }
207
+        else
208
+        {
193 209
             $ns  = "";
194 210
             $tag = $name;
195 211
         }
196 212
 
197 213
         // record root tag
198
-        if ($this->depth == 0) {
214
+        if ($this->depth == 0)
215
+        {
199 216
         	$this->root = array('name' => $tag, 'xmlns' => $ns, 'attrs' => $attrs);
200 217
         }
201 218
         // special tags at level 1: <allprop> and <propname>
202
-        if ($this->depth == 1) {
219
+        if ($this->depth == 1)
220
+        {
203 221
          	$this->use = 'props';
204 222
             switch ($tag)
205 223
             {
@@ -225,11 +243,15 @@  discard block
 block discarded – undo
225 243
         // requested properties are found at level 2
226 244
         // CalDAV filters can be at deeper levels too and we need the attrs, same for other tags (eg. multiget href's)
227 245
         if ($this->depth == 2 || $this->use == 'filters' && $this->depth >= 2 || $this->use == 'other' ||
228
-        	$this->use == 'props' && $this->depth >= 2) {
246
+        	$this->use == 'props' && $this->depth >= 2)
247
+        {
229 248
             $prop = array("name" => $tag);
230 249
             if ($ns)
231
-                $prop["xmlns"] = $ns;
232
-            if ($this->use != 'props' || $this->depth > 2) {
250
+            {
251
+                            $prop["xmlns"] = $ns;
252
+            }
253
+            if ($this->use != 'props' || $this->depth > 2)
254
+            {
233 255
             	$prop['attrs'] = $attrs;
234 256
             	$prop['depth'] = $this->depth;
235 257
             }
@@ -243,7 +265,10 @@  discard block
 block discarded – undo
243 265
             {
244 266
 	         	// this can happen if we have allprop and prop in one propfind:
245 267
 	        	// <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop
246
-	            if (!is_array($this->{$this->use}) && $this->{$this->use}) $this->{$this->use} = array($this->{$this->use});
268
+	            if (!is_array($this->{$this->use}) && $this->{$this->use})
269
+	            {
270
+	            	$this->{$this->use} = array($this->{$this->use});
271
+	            }
247 272
 	            $this->{$this->use}[] =& $prop;
248 273
 	            $this->last_prop =& $prop;
249 274
 	            unset($prop);
@@ -278,7 +303,8 @@  discard block
 block discarded – undo
278 303
      */
279 304
     function _charData($parser, $data)
280 305
     {
281
-        if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data))) {
306
+        if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data)))
307
+        {
282 308
         	$this->{$this->use}[$n-1]['data'] = $data;
283 309
         }
284 310
     }
Please login to merge, or discard this patch.
api/src/WebDAV/Server/Filesystem.php 1 patch
Braces   +212 added lines, -91 removed lines patch added patch discarded remove patch
@@ -105,15 +105,19 @@  discard block
 block discarded – undo
105 105
         // special treatment for litmus compliance test
106 106
         // reply on its identifier header
107 107
         // not needed for the test itself but eases debugging
108
-        if (isset($this->_SERVER['HTTP_X_LITMUS'])) {
108
+        if (isset($this->_SERVER['HTTP_X_LITMUS']))
109
+        {
109 110
             error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']);
110 111
             header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']);
111 112
         }
112 113
 
113 114
         // set root directory, defaults to webserver document root if not set
114
-        if ($base) {
115
+        if ($base)
116
+        {
115 117
             $this->base = realpath($base); // TODO throw if not a directory
116
-        } else if (!$this->base) {
118
+        }
119
+        else if (!$this->base)
120
+        {
117 121
             $this->base = $this->_SERVER['DOCUMENT_ROOT'];
118 122
         }
119 123
 
@@ -154,7 +158,8 @@  discard block
 block discarded – undo
154 158
         $fspath = $this->base . $options["path"];
155 159
 
156 160
         // sanity check
157
-        if (!file_exists($fspath)) {
161
+        if (!file_exists($fspath))
162
+        {
158 163
             return false;
159 164
         }
160 165
 
@@ -165,7 +170,8 @@  discard block
 block discarded – undo
165 170
         $files["files"][] = $this->fileinfo($options["path"]);
166 171
 
167 172
         // information for contained resources requested?
168
-        if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) {
173
+        if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath))
174
+        {
169 175
 
170 176
             // make sure path ends with '/'
171 177
             $options["path"] = $this->_slashify($options["path"]);
@@ -173,10 +179,13 @@  discard block
 block discarded – undo
173 179
             // try to open directory
174 180
             $handle = opendir($fspath);
175 181
 
176
-            if ($handle) {
182
+            if ($handle)
183
+            {
177 184
                 // ok, now get all its contents
178
-                while ($filename = readdir($handle)) {
179
-                    if ($filename != "." && $filename != "..") {
185
+                while ($filename = readdir($handle))
186
+                {
187
+                    if ($filename != "." && $filename != "..")
188
+                    {
180 189
                         $files["files"][] = $this->fileinfo($options["path"].$filename);
181 190
                     }
182 191
                 }
@@ -218,16 +227,22 @@  discard block
 block discarded – undo
218 227
         $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1)));
219 228
 
220 229
         // type and size (caller already made sure that path exists)
221
-        if (is_dir($fspath)) {
230
+        if (is_dir($fspath))
231
+        {
222 232
             // directory (WebDAV collection)
223 233
             $info["props"][] = $this->mkprop("resourcetype", "collection");
224 234
             $info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory");
225
-        } else {
235
+        }
236
+        else
237
+        {
226 238
             // plain file (WebDAV resource)
227 239
             $info["props"][] = $this->mkprop("resourcetype", "");
228
-            if ($this->_is_readable($fspath)) {
240
+            if ($this->_is_readable($fspath))
241
+            {
229 242
                 $info["props"][] = $this->mkprop("getcontenttype", $this->_mimetype($fspath));
230
-            } else {
243
+            }
244
+            else
245
+            {
231 246
                 $info["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable");
232 247
             }
233 248
             $info["props"][] = $this->mkprop("getcontentlength", filesize($fspath));
@@ -238,7 +253,8 @@  discard block
 block discarded – undo
238 253
                         FROM {$this->db_prefix}properties
239 254
                        WHERE path = '$path'";
240 255
         $res = mysql_query($query);
241
-        while ($row = mysql_fetch_assoc($res)) {
256
+        while ($row = mysql_fetch_assoc($res))
257
+        {
242 258
             $info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
243 259
         }
244 260
         mysql_free_result($res);
@@ -259,30 +275,45 @@  discard block
 block discarded – undo
259 275
     function _can_execute($name, $path = false)
260 276
     {
261 277
         // path defaults to PATH from environment if not set
262
-        if ($path === false) {
278
+        if ($path === false)
279
+        {
263 280
             $path = getenv("PATH");
264 281
         }
265 282
 
266 283
         // check method depends on operating system
267
-        if (!strncmp(PHP_OS, "WIN", 3)) {
284
+        if (!strncmp(PHP_OS, "WIN", 3))
285
+        {
268 286
             // on Windows an appropriate COM or EXE file needs to exist
269 287
             $exts     = array(".exe", ".com");
270 288
             $check_fn = "file_exists";
271
-        } else {
289
+        }
290
+        else
291
+        {
272 292
             // anywhere else we look for an executable file of that name
273 293
             $exts     = array("");
274 294
             $check_fn = "is_executable";
275 295
         }
276 296
 
277 297
         // now check the directories in the path for the program
278
-        foreach (explode(PATH_SEPARATOR, $path) as $dir) {
298
+        foreach (explode(PATH_SEPARATOR, $path) as $dir)
299
+        {
279 300
             // skip invalid path entries
280
-            if (!file_exists($dir)) continue;
281
-            if (!is_dir($dir)) continue;
301
+            if (!file_exists($dir))
302
+            {
303
+            	continue;
304
+            }
305
+            if (!is_dir($dir))
306
+            {
307
+            	continue;
308
+            }
282 309
 
283 310
             // and now look for the file
284
-            foreach ($exts as $ext) {
285
-                if ($check_fn("$dir/$name".$ext)) return true;
311
+            foreach ($exts as $ext)
312
+            {
313
+                if ($check_fn("$dir/$name".$ext))
314
+                {
315
+                	return true;
316
+                }
286 317
             }
287 318
         }
288 319
 
@@ -323,13 +354,18 @@  discard block
 block discarded – undo
323 354
      */
324 355
     function _mimetype($fspath)
325 356
     {
326
-        if (is_dir($fspath)) {
357
+        if (is_dir($fspath))
358
+        {
327 359
             // directories are easy
328 360
             return "httpd/unix-directory";
329
-        } else if (function_exists("mime_content_type")) {
361
+        }
362
+        else if (function_exists("mime_content_type"))
363
+        {
330 364
             // use mime magic extension if available
331 365
             $mime_type = mime_content_type($fspath);
332
-        } else if ($this->_can_execute("file")) {
366
+        }
367
+        else if ($this->_can_execute("file"))
368
+        {
333 369
             // it looks like we have a 'file' command,
334 370
             // lets see it it does have mime support
335 371
             $fp    = popen("file -i '$fspath' 2>/dev/null", "r");
@@ -341,16 +377,19 @@  discard block
 block discarded – undo
341 377
             // so we test the format of the returned string
342 378
 
343 379
             // the reply begins with the requested filename
344
-            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) {
380
+            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2))
381
+            {
345 382
                 $reply = substr($reply, strlen($fspath)+2);
346 383
                 // followed by the mime type (maybe including options)
347
-                if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) {
384
+                if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches))
385
+                {
348 386
                     $mime_type = $matches[0];
349 387
                 }
350 388
             }
351 389
         }
352 390
 
353
-        if (empty($mime_type)) {
391
+        if (empty($mime_type))
392
+        {
354 393
             // Fallback solution: try to guess the type by the file extension
355 394
             // TODO: add more ...
356 395
             // TODO: it has been suggested to delegate mimetype detection
@@ -364,7 +403,8 @@  discard block
 block discarded – undo
364 403
             //       anyway (overriding it with information taken from
365 404
             //       the registry)
366 405
             // TODO: have a seperate PEAR class for mimetype detection?
367
-            switch (strtolower(strrchr(basename($fspath), "."))) {
406
+            switch (strtolower(strrchr(basename($fspath), ".")))
407
+            {
368 408
             case ".html":
369 409
                 $mime_type = "text/html";
370 410
                 break;
@@ -395,7 +435,10 @@  discard block
 block discarded – undo
395 435
         $fspath = $this->base . $options["path"];
396 436
 
397 437
         // sanity check
398
-        if (!file_exists($fspath)) return false;
438
+        if (!file_exists($fspath))
439
+        {
440
+        	return false;
441
+        }
399 442
 
400 443
         // detect resource type
401 444
         $options['mimetype'] = $this->_mimetype($fspath);
@@ -424,12 +467,14 @@  discard block
 block discarded – undo
424 467
         $fspath = $this->base . $options["path"];
425 468
 
426 469
         // is this a collection?
427
-        if (is_dir($fspath)) {
470
+        if (is_dir($fspath))
471
+        {
428 472
             return $this->GetDir($fspath, $options);
429 473
         }
430 474
 
431 475
         // the header output is the same as for HEAD
432
-        if (!$this->HEAD($options)) {
476
+        if (!$this->HEAD($options))
477
+        {
433 478
             return false;
434 479
         }
435 480
 
@@ -451,7 +496,8 @@  discard block
 block discarded – undo
451 496
     function GetDir($fspath, &$options)
452 497
     {
453 498
         $path = $this->_slashify($options["path"]);
454
-        if ($path != $options["path"]) {
499
+        if ($path != $options["path"])
500
+        {
455 501
             header("Location: ".$this->base_uri.$path);
456 502
             exit;
457 503
         }
@@ -459,12 +505,14 @@  discard block
 block discarded – undo
459 505
         // fixed width directory column format
460 506
         $format = "%15s  %-19s  %-s\n";
461 507
 
462
-        if (!$this->_is_readable($fspath)) {
508
+        if (!$this->_is_readable($fspath))
509
+        {
463 510
             return false;
464 511
         }
465 512
 
466 513
         $handle = opendir($fspath);
467
-        if (!$handle) {
514
+        if (!$handle)
515
+        {
468 516
             return false;
469 517
         }
470 518
 
@@ -476,8 +524,10 @@  discard block
 block discarded – undo
476 524
         printf($format, "Size", "Last modified", "Filename");
477 525
         echo "<hr>";
478 526
 
479
-        while ($filename = readdir($handle)) {
480
-            if ($filename != "." && $filename != "..") {
527
+        while ($filename = readdir($handle))
528
+        {
529
+            if ($filename != "." && $filename != "..")
530
+            {
481 531
                 $fullpath = $fspath.$filename;
482 532
                 $name     = htmlspecialchars($filename);
483 533
                 printf($format,
@@ -507,19 +557,23 @@  discard block
 block discarded – undo
507 557
         $fspath = $this->base . $options["path"];
508 558
 
509 559
         $dir = dirname($fspath);
510
-        if (!file_exists($dir) || !is_dir($dir)) {
560
+        if (!file_exists($dir) || !is_dir($dir))
561
+        {
511 562
             return "409 Conflict"; // TODO right status code for both?
512 563
         }
513 564
 
514 565
         $options["new"] = ! file_exists($fspath);
515 566
 
516
-        if ($options["new"] && !$this->_is_writable($dir)) {
567
+        if ($options["new"] && !$this->_is_writable($dir))
568
+        {
517 569
             return "403 Forbidden";
518 570
         }
519
-        if (!$options["new"] && !$this->_is_writable($fspath)) {
571
+        if (!$options["new"] && !$this->_is_writable($fspath))
572
+        {
520 573
             return "403 Forbidden";
521 574
         }
522
-        if (!$options["new"] && is_dir($fspath)) {
575
+        if (!$options["new"] && is_dir($fspath))
576
+        {
523 577
             return "403 Forbidden";
524 578
         }
525 579
 
@@ -541,24 +595,30 @@  discard block
 block discarded – undo
541 595
         $parent = dirname($path);
542 596
         $name   = basename($path);
543 597
 
544
-        if (!file_exists($parent)) {
598
+        if (!file_exists($parent))
599
+        {
545 600
             return "409 Conflict";
546 601
         }
547 602
 
548
-        if (!is_dir($parent)) {
603
+        if (!is_dir($parent))
604
+        {
549 605
             return "403 Forbidden";
550 606
         }
551 607
 
552
-        if ( file_exists($parent."/".$name) ) {
608
+        if ( file_exists($parent."/".$name) )
609
+        {
553 610
             return "405 Method not allowed";
554 611
         }
555 612
 
556
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
613
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
614
+        {
615
+// no body parsing yet
557 616
             return "415 Unsupported media type";
558 617
         }
559 618
 
560 619
         $stat = mkdir($parent."/".$name, 0777);
561
-        if (!$stat) {
620
+        if (!$stat)
621
+        {
562 622
             return "403 Forbidden";
563 623
         }
564 624
 
@@ -576,16 +636,20 @@  discard block
 block discarded – undo
576 636
     {
577 637
         $path = $this->base . "/" .$options["path"];
578 638
 
579
-        if (!file_exists($path)) {
639
+        if (!file_exists($path))
640
+        {
580 641
             return "404 Not found";
581 642
         }
582 643
 
583
-        if (is_dir($path)) {
644
+        if (is_dir($path))
645
+        {
584 646
             $query = "DELETE FROM {$this->db_prefix}properties
585 647
                            WHERE path LIKE '".$this->_slashify($options["path"])."%'";
586 648
             mysql_query($query);
587 649
             System::rm(array("-rf", $path));
588
-        } else {
650
+        }
651
+        else
652
+        {
589 653
             unlink($path);
590 654
         }
591 655
         $query = "DELETE FROM {$this->db_prefix}properties
@@ -617,26 +681,35 @@  discard block
 block discarded – undo
617 681
     {
618 682
         // TODO Property updates still broken (Litmus should detect this?)
619 683
 
620
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
684
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
685
+        {
686
+// no body parsing yet
621 687
             return "415 Unsupported media type";
622 688
         }
623 689
 
624 690
         // no copying to different WebDAV Servers yet
625
-        if (isset($options["dest_url"])) {
691
+        if (isset($options["dest_url"]))
692
+        {
626 693
             return "502 bad gateway";
627 694
         }
628 695
 
629 696
         $source = $this->base . $options["path"];
630
-        if (!file_exists($source)) {
697
+        if (!file_exists($source))
698
+        {
631 699
             return "404 Not found";
632 700
         }
633 701
 
634
-        if (is_dir($source)) { // resource is a collection
635
-            switch ($options["depth"]) {
702
+        if (is_dir($source))
703
+        {
704
+// resource is a collection
705
+            switch ($options["depth"])
706
+            {
636 707
             case "infinity": // valid
637 708
                 break;
638 709
             case "0": // valid for COPY only
639
-                if ($del) { // MOVE?
710
+                if ($del)
711
+                {
712
+// MOVE?
640 713
                     return "400 Bad request";
641 714
                 }
642 715
                 break;
@@ -649,7 +722,8 @@  discard block
 block discarded – undo
649 722
         $dest         = $this->base . $options["dest"];
650 723
         $destdir      = dirname($dest);
651 724
 
652
-        if (!file_exists($destdir) || !is_dir($destdir)) {
725
+        if (!file_exists($destdir) || !is_dir($destdir))
726
+        {
653 727
             return "409 Conflict";
654 728
         }
655 729
 
@@ -657,38 +731,52 @@  discard block
 block discarded – undo
657 731
         $new          = !file_exists($dest);
658 732
         $existing_col = false;
659 733
 
660
-        if (!$new) {
661
-            if ($del && is_dir($dest)) {
662
-                if (!$options["overwrite"]) {
734
+        if (!$new)
735
+        {
736
+            if ($del && is_dir($dest))
737
+            {
738
+                if (!$options["overwrite"])
739
+                {
663 740
                     return "412 precondition failed";
664 741
                 }
665 742
                 $dest .= basename($source);
666
-                if (file_exists($dest)) {
743
+                if (file_exists($dest))
744
+                {
667 745
                     $options["dest"] .= basename($source);
668
-                } else {
746
+                }
747
+                else
748
+                {
669 749
                     $new          = true;
670 750
                     $existing_col = true;
671 751
                 }
672 752
             }
673 753
         }
674 754
 
675
-        if (!$new) {
676
-            if ($options["overwrite"]) {
755
+        if (!$new)
756
+        {
757
+            if ($options["overwrite"])
758
+            {
677 759
                 $stat = $this->DELETE(array("path" => $options["dest"]));
678
-                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
760
+                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404"))
761
+                {
679 762
                     return $stat;
680 763
                 }
681
-            } else {
764
+            }
765
+            else
766
+            {
682 767
                 return "412 precondition failed";
683 768
             }
684 769
         }
685 770
 
686
-        if ($del) {
687
-            if (!rename($source, $dest)) {
771
+        if ($del)
772
+        {
773
+            if (!rename($source, $dest))
774
+            {
688 775
                 return "500 Internal server error";
689 776
             }
690 777
             $destpath = $this->_unslashify($options["dest"]);
691
-            if (is_dir($source)) {
778
+            if (is_dir($source))
779
+            {
692 780
                 $query = "UPDATE {$this->db_prefix}properties
693 781
                                  SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
694 782
                                WHERE path LIKE '".$this->_slashify($options["path"])."%'";
@@ -699,40 +787,58 @@  discard block
 block discarded – undo
699 787
                              SET path = '".$destpath."'
700 788
                            WHERE path = '".$options["path"]."'";
701 789
             mysql_query($query);
702
-        } else {
703
-            if (is_dir($source) && $options["depth"] == "infinity") {	// no find for depth="0"
790
+        }
791
+        else
792
+        {
793
+            if (is_dir($source) && $options["depth"] == "infinity")
794
+            {
795
+// no find for depth="0"
704 796
                 $files = System::find($source);
705 797
                 $files = array_reverse($files);
706
-            } else {
798
+            }
799
+            else
800
+            {
707 801
                 $files = array($source);
708 802
             }
709 803
 
710
-            if (!is_array($files) || empty($files)) {
804
+            if (!is_array($files) || empty($files))
805
+            {
711 806
                 return "500 Internal server error";
712 807
             }
713 808
 
714 809
 
715
-            foreach ($files as $file) {
716
-                if (is_dir($file)) {
810
+            foreach ($files as $file)
811
+            {
812
+                if (is_dir($file))
813
+                {
717 814
                     $file = $this->_slashify($file);
718 815
                 }
719 816
 
720 817
                 $destfile = str_replace($source, $dest, $file);
721 818
 
722
-                if (is_dir($file)) {
723
-                    if (!file_exists($destfile)) {
724
-                        if (!$this->_is_writable(dirname($destfile))) {
819
+                if (is_dir($file))
820
+                {
821
+                    if (!file_exists($destfile))
822
+                    {
823
+                        if (!$this->_is_writable(dirname($destfile)))
824
+                        {
725 825
                             return "403 Forbidden";
726 826
                         }
727
-                        if (!mkdir($destfile)) {
827
+                        if (!mkdir($destfile))
828
+                        {
728 829
                             return "409 Conflict";
729 830
                         }
730
-                    } else if (!is_dir($destfile)) {
831
+                    }
832
+                    else if (!is_dir($destfile))
833
+                    {
731 834
                         return "409 Conflict";
732 835
                     }
733
-                } else {
836
+                }
837
+                else
838
+                {
734 839
 
735
-                    if (!copy($file, $destfile)) {
840
+                    if (!copy($file, $destfile))
841
+                    {
736 842
                         return "409 Conflict";
737 843
                     }
738 844
                 }
@@ -762,17 +868,24 @@  discard block
 block discarded – undo
762 868
         $dir  = dirname($path)."/";
763 869
         $base = basename($path);
764 870
 
765
-        foreach ($options["props"] as $key => $prop) {
766
-            if ($prop["ns"] == "DAV:") {
871
+        foreach ($options["props"] as $key => $prop)
872
+        {
873
+            if ($prop["ns"] == "DAV:")
874
+            {
767 875
                 $options["props"][$key]['status'] = "403 Forbidden";
768
-            } else {
769
-                if (isset($prop["val"])) {
876
+            }
877
+            else
878
+            {
879
+                if (isset($prop["val"]))
880
+                {
770 881
                     $query = "REPLACE INTO {$this->db_prefix}properties
771 882
                                            SET path = '$options[path]'
772 883
                                              , name = '$prop[name]'
773 884
                                              , ns= '$prop[ns]'
774 885
                                              , value = '$prop[val]'";
775
-                } else {
886
+                }
887
+                else
888
+                {
776 889
                     $query = "DELETE FROM {$this->db_prefix}properties
777 890
                                         WHERE path = '$options[path]'
778 891
                                           AND name = '$prop[name]'
@@ -799,13 +912,16 @@  discard block
 block discarded – undo
799 912
 
800 913
         // TODO recursive locks on directories not supported yet
801 914
         // makes litmus test "32. lock_collection" fail
802
-        if (is_dir($fspath) && !empty($options["depth"])) {
915
+        if (is_dir($fspath) && !empty($options["depth"]))
916
+        {
803 917
             return "409 Conflict";
804 918
         }
805 919
 
806 920
         $options["timeout"] = time()+300; // 5min. hardcoded
807 921
 
808
-        if (isset($options["update"])) { // Lock Update
922
+        if (isset($options["update"]))
923
+        {
924
+// Lock Update
809 925
             $where = "WHERE path = '$options[path]' AND token = '$options[update]'";
810 926
 
811 927
             $query = "SELECT owner, exclusivelock FROM {$this->db_prefix}locks $where";
@@ -813,7 +929,8 @@  discard block
 block discarded – undo
813 929
             $row   = mysql_fetch_assoc($res);
814 930
             mysql_free_result($res);
815 931
 
816
-            if (is_array($row)) {
932
+            if (is_array($row))
933
+            {
817 934
                 $query = "UPDATE {$this->db_prefix}locks
818 935
                                  SET expires = '$options[timeout]'
819 936
                                    , modified = ".time()."
@@ -825,7 +942,9 @@  discard block
 block discarded – undo
825 942
                 $options['type']  = $row["exclusivelock"] ? "write"     : "read";
826 943
 
827 944
                 return true;
828
-            } else {
945
+            }
946
+            else
947
+            {
829 948
                 return false;
830 949
             }
831 950
         }
@@ -876,11 +995,13 @@  discard block
 block discarded – undo
876 995
                ";
877 996
         $res = mysql_query($query);
878 997
 
879
-        if ($res) {
998
+        if ($res)
999
+        {
880 1000
             $row = mysql_fetch_array($res);
881 1001
             mysql_free_result($res);
882 1002
 
883
-            if ($row) {
1003
+            if ($row)
1004
+            {
884 1005
                 $result = array( "type"    => "write",
885 1006
                                  "scope"   => $row["exclusivelock"] ? "exclusive" : "shared",
886 1007
                                  "depth"   => 0,
Please login to merge, or discard this patch.
api/src/Header/ContentSecurityPolicy.php 1 patch
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,10 @@  discard block
 block discarded – undo
57 57
 				{
58 58
 					foreach($app_additional as $addtional)
59 59
 					{
60
-						if ($addtional) $attrs = array_unique(array_merge($attrs, $addtional));
60
+						if ($addtional)
61
+						{
62
+							$attrs = array_unique(array_merge($attrs, $addtional));
63
+						}
61 64
 					}
62 65
 				}
63 66
 			}
@@ -154,10 +157,13 @@  discard block
 block discarded – undo
154 157
 		{
155 158
 			header("X-Webkit-CSP: $csp");	// Chrome: <= 24, Safari incl. iOS
156 159
 		}
157
-		elseif ($user_agent == 'firefox' && $version < 23 || $user_agent == 'msie')	// Edge is reported as 'edge'!
160
+		elseif ($user_agent == 'firefox' && $version < 23 || $user_agent == 'msie')
161
+		{
162
+			// Edge is reported as 'edge'!
158 163
 		{
159 164
 			header("X-Content-Security-Policy: $csp");
160 165
 		}
166
+		}
161 167
 		else
162 168
 		{
163 169
 			header("Content-Security-Policy: $csp");
Please login to merge, or discard this patch.
api/src/Header/UserAgent.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,10 @@
 block discarded – undo
90 90
 			}
91 91
 		}
92 92
 		list(,self::$user_agent,self::$ua_version) = $parts;
93
-		if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera';
93
+		if ((self::$user_agent = strtolower(self::$user_agent)) == 'version')
94
+		{
95
+			self::$user_agent = 'opera';
96
+		}
94 97
 		// IE no longer reports MSIE, but "Trident/7.0; rv:11.0"
95 98
 		if (self::$user_agent=='trident')
96 99
 		{
Please login to merge, or discard this patch.
api/src/Header/Content.php 1 patch
Braces   +10 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,9 +80,13 @@  discard block
 block discarded – undo
80 80
 				// mobile FF 24 on Android does NOT honor CSP!
81 81
 				UserAgent::type() == 'firefox' && !UserAgent::mobile() && UserAgent::version() >= 24 ||
82 82
 				UserAgent::type() == 'safari' && !UserAgent::mobile() && UserAgent::version() >= 536 ||	// OS X
83
-				UserAgent::type() == 'safari' && UserAgent::mobile() && UserAgent::version() >= 9537)	// iOS 7
83
+				UserAgent::type() == 'safari' && UserAgent::mobile() && UserAgent::version() >= 9537)
84 84
 			{
85
-				$csp = "script-src 'none'";	// forbid to execute any javascript
85
+				// iOS 7
86
+			{
87
+				$csp = "script-src 'none'";
88
+			}
89
+			// forbid to execute any javascript
86 90
 				header("Content-Security-Policy: $csp");
87 91
 				header("X-Webkit-CSP: $csp");	// Chrome: <= 24, Safari incl. iOS
88 92
 				//header("X-Content-Security-Policy: $csp");	// FF <= 22
@@ -96,7 +100,10 @@  discard block
 block discarded – undo
96 100
 		}
97 101
 		if ($no_content_type)
98 102
 		{
99
-			if ($force_download) self::disposition(Api\Vfs::basename($path), $force_download);
103
+			if ($force_download)
104
+			{
105
+				self::disposition(Api\Vfs::basename($path), $force_download);
106
+			}
100 107
 		}
101 108
 		else
102 109
 		{
Please login to merge, or discard this patch.
api/src/Header/Referer.php 1 patch
Braces   +14 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,12 +29,19 @@  discard block
 block discarded – undo
29 29
 	static function get($default='',$referer='')
30 30
 	{
31 31
 		// HTTP_REFERER seems NOT to get urldecoded
32
-		if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']);
32
+		if (!$referer)
33
+		{
34
+			$referer = urldecode($_SERVER['HTTP_REFERER']);
35
+		}
33 36
 
34 37
 		$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
35
-		if (empty($webserver_url) || $webserver_url{0} == '/')	// url is just a path
38
+		if (empty($webserver_url) || $webserver_url{0} == '/')
39
+		{
40
+			// url is just a path
36 41
 		{
37
-			$referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer);	// removing the domain part
42
+			$referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer);
43
+		}
44
+		// removing the domain part
38 45
 		}
39 46
 		if (strlen($webserver_url) > 1)
40 47
 		{
@@ -42,7 +49,10 @@  discard block
 block discarded – undo
42 49
 		}
43 50
 		$ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer);
44 51
 
45
-		if (empty($ret) || strpos($ret, 'cd=yes') !== false) $ret = $default;
52
+		if (empty($ret) || strpos($ret, 'cd=yes') !== false)
53
+		{
54
+			$ret = $default;
55
+		}
46 56
 
47 57
 		return $ret;
48 58
 	}
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Entry.php 1 patch
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,7 +71,10 @@  discard block
 block discarded – undo
71 71
 		$data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX . $this->id);
72 72
 
73 73
 		// No need to proceed
74
-		if(!$data_id) return;
74
+		if(!$data_id)
75
+		{
76
+			return;
77
+		}
75 78
 
76 79
 		// Find out which record to load
77 80
 		$value = self::get_array(self::$request->content, $form_name, false, true);
@@ -93,7 +96,10 @@  discard block
 block discarded – undo
93 96
 
94 97
 		// Set the new value so transformer can find it.  Use prefix to avoid changing the original value
95 98
 		$new_value =& self::get_array(self::$request->content, self::ID_PREFIX .$this->id, true, false);
96
-		if (true) $new_value = $data;
99
+		if (true)
100
+		{
101
+			$new_value = $data;
102
+		}
97 103
 		$this->id = self::ID_PREFIX . $this->id . "[{$attrs['field']}]";
98 104
 
99 105
 		$old_type = self::getElementAttribute($this->id, 'type');
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Url.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,7 +114,10 @@
 block discarded – undo
114 114
 						break;
115 115
 				}
116 116
 			}
117
-			if (true) $valid = $value;
117
+			if (true)
118
+			{
119
+				$valid = $value;
120
+			}
118 121
 			//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value));
119 122
 		}
120 123
 	}
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Template.php 1 patch
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,7 +86,10 @@  discard block
 block discarded – undo
86 86
 					}
87 87
 
88 88
 					$parts = explode('.',$c_name);
89
-					if($name == $parts[count($parts)-1]) return $c_template;
89
+					if($name == $parts[count($parts)-1])
90
+					{
91
+						return $c_template;
92
+					}
90 93
 				}
91 94
 			}
92 95
 			// Template not found, try again with content expansion
@@ -106,7 +109,10 @@  discard block
 block discarded – undo
106 109
 			return false;
107 110
 		}
108 111
 		$reader = new XMLReader();
109
-		if (!$reader->open(self::rel2path($path))) return false;
112
+		if (!$reader->open(self::rel2path($path)))
113
+		{
114
+			return false;
115
+		}
110 116
 
111 117
 		while($reader->read())
112 118
 		{
@@ -208,7 +214,10 @@  discard block
 block discarded – undo
208 214
 			{
209 215
 				$url = Api\Vfs::download_url($path);
210 216
 
211
-				if ($url[0] == '/') $url = Api\Framework::link($url);
217
+				if ($url[0] == '/')
218
+				{
219
+					$url = Api\Framework::link($url);
220
+				}
212 221
 
213 222
 				// mtime postfix has to use '?download=', as our WebDAV treats everything else literal and not ignore them like Apache for static files!
214 223
 				$url .= '?download='.filemtime($path);
@@ -231,7 +240,10 @@  discard block
 block discarded – undo
231 240
 	{
232 241
 		$cname =& $params[0];
233 242
 		$old_cname = $params[0];
234
-		if ($this->attrs['content']) $cname = self::form_name($cname, $this->attrs['content'], $params[1]);
243
+		if ($this->attrs['content'])
244
+		{
245
+			$cname = self::form_name($cname, $this->attrs['content'], $params[1]);
246
+		}
235 247
 
236 248
 		// Check for template from content, and run over it
237 249
 		// templates included via template tag have their name to load them from in attribute "template"
Please login to merge, or discard this patch.