GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#34)
by
unknown
02:32
created
lib/CardDAV-PHP/carddav.php 1 patch
Braces   +86 added lines, -38 removed lines patch added patch discarded remove patch
@@ -219,7 +219,8 @@  discard block
 block discarded – undo
219 219
      */
220 220
     public function __construct($url = null)
221 221
     {
222
-        if ($url !== null) {
222
+        if ($url !== null)
223
+        {
223 224
             $this->setUrl($url);
224 225
         }
225 226
     }
@@ -245,7 +246,8 @@  discard block
 block discarded – undo
245 246
     {
246 247
         $this->url = $url;
247 248
 
248
-        if (substr($this->url, -1, 1) !== '/') {
249
+        if (substr($this->url, -1, 1) !== '/')
250
+        {
249 251
             $this->url = $this->url . '/';
250 252
         }
251 253
 
@@ -339,9 +341,12 @@  discard block
 block discarded – undo
339 341
         {
340 342
             case 200:
341 343
             case 207:
342
-                if ($raw === true) {
344
+                if ($raw === true)
345
+                {
343 346
                     return $result['response'];
344
-                } else {
347
+                }
348
+                else
349
+                {
345 350
                     return $this->simplify($result['response'], $include_vcards);
346 351
                 }
347 352
         }
@@ -368,13 +373,13 @@  discard block
 block discarded – undo
368 373
         // print_r($result);
369 374
 
370 375
 	switch ($result['http_code'])
371
-        {
376
+	{
372 377
 		case 404:
373 378
 			$altResult  = $this->query($this->url . $vcard_id , 'GET');
374 379
 		        // DEBUG: print the response of the carddav-server
375 380
 		        // print_r($altResult);
376 381
 	                switch ($altResult['http_code'])
377
-        	        {
382
+	                {
378 383
                 	        case 200:
379 384
 	                        case 207:
380 385
 					print "Ignoring given Vcard Extension (".$this->url_vcard_extension.")" . PHP_EOL. ".";
@@ -458,9 +463,12 @@  discard block
 block discarded – undo
458 463
     {
459 464
         $result = $this->query($this->url, 'OPTIONS');
460 465
 
461
-        if ($result['http_code'] === 200) {
466
+        if ($result['http_code'] === 200)
467
+        {
462 468
             return true;
463
-        } else {
469
+        }
470
+        else
471
+        {
464 472
             return false;
465 473
         }
466 474
     }
@@ -509,7 +517,8 @@  discard block
 block discarded – undo
509 517
      */
510 518
     public function add($vcard, $vcard_id = null)
511 519
     {
512
-        if ($vcard_id === null) {
520
+        if ($vcard_id === null)
521
+        {
513 522
             $vcard_id   = $this->generateVcardId();
514 523
         }
515 524
         $vcard  = $this->cleanVcard($vcard);
@@ -536,9 +545,12 @@  discard block
 block discarded – undo
536 545
      */
537 546
     public function update($vcard, $vcard_id)
538 547
     {
539
-        try {
548
+        try
549
+        {
540 550
             return $this->add($vcard, $vcard_id);
541
-        } catch (Exception $e) {
551
+        }
552
+        catch (Exception $e)
553
+        {
542 554
             throw new \Exception($e->getMessage(), self::EXCEPTION_WRONG_HTTP_STATUS_CODE_UPDATE);
543 555
         }
544 556
     }
@@ -554,9 +566,12 @@  discard block
 block discarded – undo
554 566
     {
555 567
         $response = $this->cleanResponse($response);
556 568
 
557
-        try {
569
+        try
570
+        {
558 571
             $xml = new \SimpleXMLElement($response);
559
-        } catch (Exception $e) {
572
+        }
573
+        catch (Exception $e)
574
+        {
560 575
             throw new \Exception(
561 576
                 "The XML response seems to be malformed and can't be simplified!",
562 577
                 self::EXCEPTION_MALFORMED_XML_RESPONSE,
@@ -571,35 +586,50 @@  discard block
 block discarded – undo
571 586
         $simplified_xml->startDocument('1.0', 'utf-8');
572 587
             $simplified_xml->startElement('response');
573 588
 
574
-        if (!empty($xml->response)) {
575
-            foreach ($xml->response as $response) {
589
+        if (!empty($xml->response))
590
+        {
591
+            foreach ($xml->response as $response)
592
+            {
576 593
               if ((preg_match('/vcard/', $response->propstat->prop->getcontenttype) || preg_match('/vcf/', $response->href)) &&
577
-                  !$response->propstat->prop->resourcetype->collection) {
594
+                  !$response->propstat->prop->resourcetype->collection)
595
+              {
578 596
                     $id = basename($response->href);
579 597
                     $id = str_replace($this->url_vcard_extension, null, $id);
580 598
 
581
-                    try {
599
+                    try
600
+                    {
582 601
                         $vcardData = $this->getVcard($id);
583
-                        if (!empty($id)) {
602
+                        if (!empty($id))
603
+                        {
584 604
                             $simplified_xml->startElement('element');
585 605
                                 $simplified_xml->writeElement('id', $id);
586 606
                                 $simplified_xml->writeElement('etag', str_replace('"', null, $response->propstat->prop->getetag));
587 607
                                 $simplified_xml->writeElement('last_modified', $response->propstat->prop->getlastmodified);
588 608
 
589
-                            if ($include_vcards === true) {
609
+                            if ($include_vcards === true)
610
+                            {
590 611
                                 $simplified_xml->writeElement('vcard', $vcardData);
591 612
                             }
592 613
                             $simplified_xml->endElement();
593 614
                         }
594
-                    } catch (\Exception $e) {
615
+                    }
616
+                    catch (\Exception $e)
617
+                    {
595 618
                         print("Error fetching vCard: {$id}: {$e->getMessage()}\n");
596 619
                     }
597
-                } elseif (preg_match('/unix-directory/', $response->propstat->prop->getcontenttype)) {
598
-                    if (isset($response->propstat->prop->href)) {
620
+                }
621
+                elseif (preg_match('/unix-directory/', $response->propstat->prop->getcontenttype))
622
+                {
623
+                    if (isset($response->propstat->prop->href))
624
+                    {
599 625
                         $href = $response->propstat->prop->href;
600
-                    } elseif (isset($response->href)) {
626
+                    }
627
+                    elseif (isset($response->href))
628
+                    {
601 629
                         $href = $response->href;
602
-                    } else {
630
+                    }
631
+                    else
632
+                    {
603 633
                         $href = null;
604 634
                     }
605 635
 
@@ -643,7 +673,8 @@  discard block
 block discarded – undo
643 673
      */
644 674
     public function curlInit()
645 675
     {
646
-        if (empty($this->curl)) {
676
+        if (empty($this->curl))
677
+        {
647 678
             $this->curl = curl_init();
648 679
             curl_setopt($this->curl, CURLOPT_HEADER, true);
649 680
             curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
@@ -651,7 +682,8 @@  discard block
 block discarded – undo
651 682
             curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
652 683
             curl_setopt($this->curl, CURLOPT_USERAGENT, self::USERAGENT.self::VERSION);
653 684
 
654
-            if ($this->auth !== null) {
685
+            if ($this->auth !== null)
686
+            {
655 687
                 curl_setopt($this->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
656 688
                 curl_setopt($this->curl, CURLOPT_USERPWD, $this->auth);
657 689
             }
@@ -681,17 +713,23 @@  discard block
 block discarded – undo
681 713
         curl_setopt($this->curl, CURLOPT_URL, $url);
682 714
         curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $method);
683 715
 
684
-        if ($content !== null) {
716
+        if ($content !== null)
717
+        {
685 718
             curl_setopt($this->curl, CURLOPT_POST, true);
686 719
             curl_setopt($this->curl, CURLOPT_POSTFIELDS, $content);
687
-        } else {
720
+        }
721
+        else
722
+        {
688 723
             curl_setopt($this->curl, CURLOPT_POST, false);
689 724
             curl_setopt($this->curl, CURLOPT_POSTFIELDS, null);
690 725
         }
691 726
 
692
-        if ($content_type !== null) {
727
+        if ($content_type !== null)
728
+        {
693 729
             curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Content-type: '.$content_type, 'Depth: 1'));
694
-        } else {
730
+        }
731
+        else
732
+        {
695 733
             curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('Depth: 1'));
696 734
         }
697 735
 
@@ -706,7 +744,8 @@  discard block
 block discarded – undo
706 744
             'http_code'         => $http_code
707 745
         );
708 746
 
709
-        if ($this->debug === true) {
747
+        if ($this->debug === true)
748
+        {
710 749
             $debug = $return;
711 750
             $debug['url']           = $url;
712 751
             $debug['method']        = $method;
@@ -728,26 +767,34 @@  discard block
 block discarded – undo
728 767
     {
729 768
         $vcard_id = null;
730 769
 
731
-        for ($number = 0; $number <= 25; $number ++) {
732
-            if ($number == 8 || $number == 17) {
770
+        for ($number = 0; $number <= 25; $number ++)
771
+        {
772
+            if ($number == 8 || $number == 17)
773
+            {
733 774
                 $vcard_id .= '-';
734
-            } else {
775
+            }
776
+            else
777
+            {
735 778
                 $vcard_id .= $this->vcard_id_chars[mt_rand(0, (count($this->vcard_id_chars) - 1))];
736 779
             }
737 780
         }
738 781
 
739
-        try {
782
+        try
783
+        {
740 784
             $carddav = new CardDavBackend($this->url);
741 785
             $carddav->setAuth($this->username, $this->password);
742 786
 
743 787
             $result = $carddav->query($this->url . $vcard_id . $this->url_vcard_extension, 'GET');
744 788
 
745
-            if ($result['http_code'] !== 404) {
789
+            if ($result['http_code'] !== 404)
790
+            {
746 791
                 $vcard_id = $this->generateVcardId();
747 792
             }
748 793
 
749 794
             return $vcard_id;
750
-        } catch (Exception $e) {
795
+        }
796
+        catch (Exception $e)
797
+        {
751 798
             throw new \Exception($e->getMessage(), self::EXCEPTION_COULD_NOT_GENERATE_NEW_VCARD_ID);
752 799
         }
753 800
     }
@@ -760,7 +807,8 @@  discard block
 block discarded – undo
760 807
      */
761 808
     public function __destruct()
762 809
     {
763
-        if (!empty($this->curl)) {
810
+        if (!empty($this->curl))
811
+        {
764 812
             curl_close($this->curl);
765 813
         }
766 814
     }
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_ring_phone.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 // init the output message
4 4
 $message = date('Y-m-d H:i') . ' ';
5 5
 try
6
-{ 
6
+{
7 7
   // load the fritzbox_api class
8 8
   require_once(__DIR__ . '/fritzbox_api.class.php');
9 9
   $fritz = new fritzbox_api();
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_api.class.php 1 patch
Braces   +41 added lines, -20 removed lines patch added patch discarded remove patch
@@ -46,7 +46,8 @@  discard block
 block discarded – undo
46 46
  * the main Fritz!Box API class
47 47
  *
48 48
  */
49
-class fritzbox_api {
49
+class fritzbox_api
50
+{
50 51
   /**
51 52
     * @var  object  config object
52 53
     */
@@ -69,7 +70,8 @@  discard block
 block discarded – undo
69 70
 	$this->config = new fritzbox_api_config();
70 71
     
71 72
 	// try autoloading the config
72
-	if (file_exists(__DIR__ . '/fritzbox_user.conf.php') && is_readable(__DIR__ . '/fritzbox_user.conf.php') ) {
73
+	if (file_exists(__DIR__ . '/fritzbox_user.conf.php') && is_readable(__DIR__ . '/fritzbox_user.conf.php') )
74
+	{
73 75
 		require_once(__DIR__ . '/fritzbox_user.conf.php');
74 76
 	}
75 77
 
@@ -77,29 +79,37 @@  discard block
 block discarded – undo
77 79
 	$this->config->setItem('fritzbox_ip',$fritzbox_ip);
78 80
 
79 81
 	// check if login on local network (fritz.box) or via a dynamic DNS-host
80
-	if ($fritzbox_ip != 'fritz.box' && !$force_local_login) {
82
+	if ($fritzbox_ip != 'fritz.box' && !$force_local_login)
83
+	{
81 84
 		$this->config->setItem('enable_remote_config',true);
82 85
 		$this->config->setItem('remote_config_user',$user_name);
83 86
 		$this->config->setItem('remote_config_password',$password);
84 87
 		$this->config->setItem('fritzbox_url', 'https://'.$this->config->getItem('fritzbox_ip'));
85
-	} else {
88
+	}
89
+	else
90
+	{
86 91
 		$this->config->setItem('enable_remote_config',false);
87
-		if($user_name != false){
92
+		if($user_name != false)
93
+		{
88 94
 			$this->config->setItem('username',$user_name);
89 95
 		}
90
-		if($password != false){
96
+		if($password != false)
97
+		{
91 98
 			$this->config->setItem('password',$password);
92 99
 		}
93 100
 		$this->config->setItem('fritzbox_url', 'http://' . $this->config->getItem('fritzbox_ip'));
94 101
 	}
95 102
 
96 103
 	// make some config consistency checks
97
-	if ( $this->config->getItem('enable_remote_config') === true ){
98
-		if ( !$this->config->getItem('remote_config_user') || !$this->config->getItem('remote_config_password') ){
104
+	if ( $this->config->getItem('enable_remote_config') === true )
105
+	{
106
+		if ( !$this->config->getItem('remote_config_user') || !$this->config->getItem('remote_config_password') )
107
+		{
99 108
 		  $this->error('ERROR: Remote config mode enabled, but no username or no password provided');
100 109
 		}
101 110
 	}
102
-	else {
111
+	else
112
+	{
103 113
 		$this->config->setItem('old_remote_config_user', null);
104 114
 		$this->config->setItem('old_remote_config_password', null);
105 115
 	}
@@ -148,10 +158,13 @@  discard block
 block discarded – undo
148 158
     if ( $this->config->getItem('enable_remote_config') == true )
149 159
     {
150 160
 		// set name of SSL-certificate (must be same as remote-hostname (dynDNS) of FRITZ!Box) and remove port in address if alternate port is given
151
-		if (strpos($this->config->getItem('fritzbox_ip'),":")){
161
+		if (strpos($this->config->getItem('fritzbox_ip'),":"))
162
+		{
152 163
 			$ssl_cert_fritzbox = explode(":", $this->config->getItem('fritzbox_ip'));
153 164
 			$ssl_cert_fritzbox = $ssl_cert_fritzbox[0];
154
-		} else {
165
+		}
166
+		else
167
+		{
155 168
 			$ssl_cert_fritzbox = $this->config->getItem('fritzbox_ip');
156 169
 		}
157 170
 
@@ -162,7 +175,8 @@  discard block
 block discarded – undo
162 175
 		curl_setopt($ch, CURLOPT_CAPATH, '/etc/ssl/certs');
163 176
 
164 177
 		// support for pre FRITZ!OS 5.50 remote config
165
-		if (!$this->config->getItem('use_lua_login_method')){
178
+		if (!$this->config->getItem('use_lua_login_method'))
179
+		{
166 180
 		curl_setopt($ch, CURLOPT_USERPWD, $this->config->getItem('remote_config_user') . ':' . $this->config->getItem('remote_config_password'));
167 181
 		}
168 182
     }
@@ -173,7 +187,7 @@  discard block
 block discarded – undo
173 187
   }
174 188
 
175 189
   public function doPostFile($formfields = array(), $filefileds = array())
176
-  {  
190
+  {
177 191
     $ch = curl_init();
178 192
    
179 193
     // add the sid, if it is already set
@@ -192,11 +206,13 @@  discard block
 block discarded – undo
192 206
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
193 207
     
194 208
     // if filefileds not specified ('@/path/to/file.xml;type=text/xml' works fine)
195
-    if(empty( $filefileds )) {
209
+    if(empty( $filefileds ))
210
+    {
196 211
 		curl_setopt($ch, CURLOPT_POSTFIELDS, $formfields); // http_build_query
197 212
 	} 
198 213
 	// post calculated raw data
199
-	else {
214
+	else
215
+	{
200 216
 		$header = $this->_create_custom_file_post_header($formfields, $filefileds);
201 217
 		curl_setopt($ch, CURLOPT_HTTPHEADER , array(
202 218
 			'Content-Type: multipart/form-data; boundary=' . $header['delimiter'], 'Content-Length: ' . strlen($header['data']) )
@@ -208,7 +224,8 @@  discard block
 block discarded – undo
208 224
     $output = curl_exec($ch);
209 225
 
210 226
 	// curl error
211
-	if(curl_errno($ch)) {
227
+	if(curl_errno($ch))
228
+	{
212 229
 		$this->error(curl_error($ch)." (".curl_errno($ch).")");
213 230
 	}
214 231
 
@@ -223,7 +240,8 @@  discard block
 block discarded – undo
223 240
     return $output;
224 241
   }
225 242
 
226
-  private function _create_custom_file_post_header($postFields, $fileFields) {
243
+  private function _create_custom_file_post_header($postFields, $fileFields)
244
+  {
227 245
 		// form field separator
228 246
 		$delimiter = '-------------' . uniqid();
229 247
 		
@@ -245,7 +263,8 @@  discard block
 block discarded – undo
245 263
 		$data = '';
246 264
 
247 265
 		// populate normal fields first (simpler)
248
-		foreach ($postFields as $name => $content) {
266
+		foreach ($postFields as $name => $content)
267
+		{
249 268
 		   $data .= "--" . $delimiter . "\r\n";
250 269
 			$data .= 'Content-Disposition: form-data; name="' . urlencode($name) . '"';
251 270
 			$data .= "\r\n\r\n";
@@ -253,7 +272,8 @@  discard block
 block discarded – undo
253 272
 			$data .= "\r\n";
254 273
 		}
255 274
 		// populate file fields
256
-		foreach ($fileFields as $name => $file) {
275
+		foreach ($fileFields as $name => $file)
276
+		{
257 277
 			$data .= "--" . $delimiter . "\r\n";
258 278
 			// "filename" attribute is not essential; server-side scripts may use it
259 279
 			$data .= 'Content-Disposition: form-data; name="' . urlencode($name) . '";' .
@@ -479,7 +499,8 @@  discard block
 block discarded – undo
479 499
   }
480 500
 }
481 501
 
482
-class fritzbox_api_config {
502
+class fritzbox_api_config
503
+{
483 504
   protected $config = array();
484 505
 
485 506
   public function __construct()
Please login to merge, or discard this patch.
lib/vCard-parser/vCard.php 1 patch
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -225,10 +225,13 @@  discard block
 block discarded – undo
225 225
 									{
226 226
 										//$Value = base64_decode($Value);
227 227
 									}
228
-									elseif ($ParamValue == 'quoted-printable') // v2.1
228
+									elseif ($ParamValue == 'quoted-printable')
229
+									{
230
+									  // v2.1
229 231
 									{
230 232
 										$Value = quoted_printable_decode($Value);
231 233
 									}
234
+									}
232 235
 									break;
233 236
 								case 'charset': // v2.1
234 237
 									if ($ParamValue != 'utf-8' && $ParamValue != 'utf8')
@@ -407,8 +410,7 @@  discard block
 block discarded – undo
407 410
 
408 411
 				if (isset(self::$Spec_StructuredElements[$Key]) &&
409 412
 					in_array(strtolower($Arguments[1]), self::$Spec_StructuredElements[$Key])
410
-				)
411
-				{
413
+				) {
412 414
 					$LastElementIndex = 0;
413 415
 
414 416
 					if (count($this -> Data[$Key]))
@@ -596,8 +598,7 @@  discard block
 block discarded – undo
596 598
 					if (
597 599
 						(isset(self::$Spec_ElementTypes[$Key]) && in_array($Parameter[0], self::$Spec_ElementTypes[$Key])) ||
598 600
 						($Key == 'email' && is_scalar($Parameter[0]))
599
-					)
600
-					{
601
+					) {
601 602
 						$Type[] = $Parameter[0];
602 603
 					}
603 604
 				}
Please login to merge, or discard this patch.
carddav2fb.php 1 patch
Braces   +218 added lines, -97 removed lines patch added patch discarded remove patch
@@ -38,9 +38,12 @@  discard block
 block discarded – undo
38 38
 require_once('lib/fritzbox_api_php/fritzbox_api.class.php');
39 39
 
40 40
 if($argc == 2)
41
+{
41 42
   $config_file_name = $argv[1];
42
-else
43
+}
44
+else {
43 45
   $config_file_name = __DIR__ . '/config.php';
46
+}
44 47
 
45 48
 // default/fallback config options
46 49
 $config['tmp_dir'] = sys_get_temp_dir();
@@ -60,7 +63,9 @@  discard block
 block discarded – undo
60 63
 $config['quickdial_keyword'] = 'Quickdial:';
61 64
 
62 65
 if(is_file($config_file_name))
66
+{
63 67
   require($config_file_name);
68
+}
64 69
 else
65 70
 {
66 71
   print 'ERROR: No ' . $config_file_name . ' found, please take a look at config.example.php and create a ' . $config_file_name . ' file!' . PHP_EOL;
@@ -122,7 +127,9 @@  discard block
 block discarded – undo
122 127
   public function mktemp($dir, $prefix = '', $mode = 0700)
123 128
   {
124 129
     if(substr($dir, -1) != '/')
125
-      $dir .= '/';
130
+    {
131
+          $dir .= '/';
132
+    }
126 133
 
127 134
     do
128 135
     {
@@ -143,7 +150,12 @@  discard block
 block discarded – undo
143 150
         if($object != "." && $object != "..")
144 151
         {
145 152
           if(filetype($dir . "/" . $object) == "dir")
146
-            rrmdir($dir . "/" . $object); else unlink($dir . "/" . $object);
153
+          {
154
+                      rrmdir($dir . "/" . $object);
155
+          }
156
+          else {
157
+              unlink($dir . "/" . $object);
158
+            }
147 159
         }
148 160
       }
149 161
       reset($objects);
@@ -157,18 +169,25 @@  discard block
 block discarded – undo
157 169
     {
158 170
       // Check if there are valid base64 characters
159 171
       if(!preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $str))
160
-        return false;
172
+      {
173
+              return false;
174
+      }
161 175
 
162 176
       // Decode the string in strict mode and check the results
163 177
       $decoded = base64_decode($str, true);
164 178
       if($decoded === false)
165
-        return false;
179
+      {
180
+              return false;
181
+      }
166 182
 
167 183
       // Encode the string again
168 184
       if(base64_encode($decoded) === $str)
169
-        return true;
170
-      else
171
-        return false;
185
+      {
186
+              return true;
187
+      }
188
+      else {
189
+              return false;
190
+      }
172 191
     }
173 192
     catch(Exception $e)
174 193
     {
@@ -209,7 +228,9 @@  discard block
 block discarded – undo
209 228
         // set the vcard extension in case the user
210 229
         // defined it in the config
211 230
         if(isset($conf['extension']))
212
-          $carddav->setVcardExtension($conf['extension']);
231
+        {
232
+                  $carddav->setVcardExtension($conf['extension']);
233
+        }
213 234
 
214 235
         // retrieve data from the CardDAV server now
215 236
         $xmldata = $carddav->get();
@@ -218,7 +239,9 @@  discard block
 block discarded – undo
218 239
         // CardDAV server and if not reencode it since the FRITZ!Box
219 240
         // requires UTF-8 encoded data
220 241
         if(iconv('utf-8', 'utf-8//IGNORE', $xmldata) != $xmldata)
221
-          $xmldata = utf8_encode($xmldata);
242
+        {
243
+                  $xmldata = utf8_encode($xmldata);
244
+        }
222 245
 
223 246
         // read raw_vcard data from xml response
224 247
         $raw_vcards = array();
@@ -240,10 +263,14 @@  discard block
 block discarded – undo
240 263
           $vcard_obj = new vCard(false, $v);
241 264
           $name_arr = null;
242 265
           if(isset($vcard_obj->n[0]))
243
-            $name_arr = $vcard_obj->n[0];
266
+          {
267
+                      $name_arr = $vcard_obj->n[0];
268
+          }
244 269
           $org_arr = null;
245 270
           if(isset($vcard_obj->org[0]))
246
-            $org_arr = $vcard_obj->org[0];
271
+          {
272
+                      $org_arr = $vcard_obj->org[0];
273
+          }
247 274
           $addnames = '';
248 275
           $prefix = '';
249 276
           $suffix = '';
@@ -252,19 +279,29 @@  discard block
 block discarded – undo
252 279
 
253 280
           // Build name Parts if existing ans switch to true in config
254 281
           if(isset($name_arr['prefixes']) and $this->config['prefix'])
255
-            $prefix = trim($name_arr['prefixes']);
282
+          {
283
+                      $prefix = trim($name_arr['prefixes']);
284
+          }
256 285
 
257 286
           if(isset($name_arr['suffixes']) and $this->config['suffix'])
258
-            $suffix = trim($name_arr['suffixes']);
287
+          {
288
+                      $suffix = trim($name_arr['suffixes']);
289
+          }
259 290
 
260 291
           if(isset($name_arr['additionalnames']) and $this->config['addnames'])
261
-            $addnames = trim($name_arr['additionalnames']);
292
+          {
293
+                      $addnames = trim($name_arr['additionalnames']);
294
+          }
262 295
 
263 296
           if(isset($org_arr['name']) and $this->config['orgname'])
264
-            $orgname = trim($org_arr['name']);
297
+          {
298
+                      $orgname = trim($org_arr['name']);
299
+          }
265 300
 
266 301
           if (isset($vcard_obj->fn[0]))
267
-            $formattedname = $vcard_obj->fn[0];
302
+          {
303
+                      $formattedname = $vcard_obj->fn[0];
304
+          }
268 305
 
269 306
           $firstname = trim($name_arr['firstname']);
270 307
           $lastname = trim($name_arr['lastname']);
@@ -284,78 +321,106 @@  discard block
 block discarded – undo
284 321
 
285 322
           // Prefix
286 323
           if(!empty($prefix))
287
-            $name .= $prefix;
324
+          {
325
+                      $name .= $prefix;
326
+          }
288 327
 
289 328
           if($format == 0)
290 329
           {
291 330
             // Lastname
292 331
             if(!empty($name) and !empty($lastname))
293
-              $name .= ' ' . $lastname;
294
-            else
295
-              $name .= $lastname;
332
+            {
333
+                          $name .= ' ' . $lastname;
334
+            }
335
+            else {
336
+                          $name .= $lastname;
337
+            }
296 338
           }
297 339
           else
298 340
           {
299 341
             // Firstname
300 342
             if(!empty($name) and !empty($firstname))
301
-              $name .= ' ' . $firstname;
302
-            else
303
-              $name .= $firstname;
343
+            {
344
+                          $name .= ' ' . $firstname;
345
+            }
346
+            else {
347
+                          $name .= $firstname;
348
+            }
304 349
           }
305 350
 
306 351
           if($format == 2)
307 352
           {
308 353
             // AdditionalNames
309 354
             if(!empty($name) and !empty($addnames))
310
-              $name .= ' ' . $addnames;
311
-            else
312
-              $name .= $addnames;
355
+            {
356
+                          $name .= ' ' . $addnames;
357
+            }
358
+            else {
359
+                          $name .= $addnames;
360
+            }
313 361
           }
314 362
 
315 363
           if($format == 0)
316 364
           {
317 365
             // Firstname
318 366
             if(!empty($name) and !empty($firstname))
319
-              $name .= ', ' . $firstname;
320
-            else
321
-              $name .= $firstname;
367
+            {
368
+                          $name .= ', ' . $firstname;
369
+            }
370
+            else {
371
+                          $name .= $firstname;
372
+            }
322 373
           }
323 374
           else
324 375
           {
325 376
             // Lastname
326 377
             if(!empty($name) and !empty($lastname))
327
-              $name .= ' ' . $lastname;
328
-            else
329
-              $name .= $lastname;
378
+            {
379
+                          $name .= ' ' . $lastname;
380
+            }
381
+            else {
382
+                          $name .= $lastname;
383
+            }
330 384
           }
331 385
 
332 386
           if($format != 2)
333 387
           {
334 388
             // AdditionalNames
335 389
             if(!empty($name) and !empty($addnames))
336
-              $name .= ' ' . $addnames;
337
-            else
338
-              $name .= $addnames;
390
+            {
391
+                          $name .= ' ' . $addnames;
392
+            }
393
+            else {
394
+                          $name .= $addnames;
395
+            }
339 396
           }
340 397
 
341 398
           // Suffix
342 399
           if(!empty($name) and !empty($suffix))
343
-            $name .= ' ' . $suffix;
344
-          else
345
-            $name .= $suffix;
400
+          {
401
+                      $name .= ' ' . $suffix;
402
+          }
403
+          else {
404
+                      $name .= $suffix;
405
+          }
346 406
 
347 407
           // OrgName
348 408
           if(!empty($name) and !empty($orgname))
349
-            $name .= ' (' . $orgname . ')';
350
-          else
351
-            $name .= $orgname;
409
+          {
410
+                      $name .= ' (' . $orgname . ')';
411
+          }
412
+          else {
413
+                      $name .= $orgname;
414
+          }
352 415
 
353 416
           // make sure to trim whitespaces and double spaces
354 417
           $name = trim(str_replace('  ', ' ', $name));
355 418
 
356 419
           // perform a fallback to formatted name, if we don't have any name and formatted name is available
357 420
           if(empty($name) and !empty($formattedname))
358
-            $name = $formattedname;
421
+          {
422
+                      $name = $formattedname;
423
+          }
359 424
 
360 425
           if(empty($name))
361 426
           {
@@ -369,15 +434,19 @@  discard block
 block discarded – undo
369 434
             $photo = str_replace(array(',', '&', ' ', '/', 'ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß', 'á', 'à', 'ó', 'ò', 'ú', 'ù', 'í', 'ø'),
370 435
             array('', '_', '_', '_', 'ae', 'oe', 'ue', 'Ae', 'Oe', 'Ue', 'ss', 'a', 'a', 'o', 'o', 'u', 'u', 'i', 'oe'), $name);
371 436
           }
372
-          else
373
-            $photo = '';
437
+          else {
438
+                      $photo = '';
439
+          }
374 440
 
375 441
           // phone
376 442
           $phone_no = array();
377 443
           if($vcard_obj->categories)
378
-            $categories = $vcard_obj->categories[0];
379
-          else
380
-            $categories = array();
444
+          {
445
+                      $categories = $vcard_obj->categories[0];
446
+          }
447
+          else {
448
+                      $categories = array();
449
+          }
381 450
 
382 451
           // check for quickdial entry
383 452
           if(isset($vcard_obj->note[0]))
@@ -412,9 +481,10 @@  discard block
 block discarded – undo
412 481
                 break;
413 482
               }
414 483
             }
415
-          } 
416
-          else
417
-            $add_entry = 1;
484
+          }
485
+          else {
486
+                      $add_entry = 1;
487
+          }
418 488
 
419 489
           if($add_entry == 1)
420 490
           {
@@ -439,9 +509,13 @@  discard block
 block discarded – undo
439 509
                   {
440 510
                     //Set quickdial
441 511
                     if($value == 1)
442
-                      print "\nWARNING: Quickdial value 1 (**701) is not possible but used! \n";
512
+                    {
513
+                                          print "\nWARNING: Quickdial value 1 (**701) is not possible but used! \n";
514
+                    }
443 515
                     elseif($value >= 100)
444
-                      print "\nWARNING: Quickdial value bigger than 99 (**799) is not possible but used! \n";
516
+                    {
517
+                                          print "\nWARNING: Quickdial value bigger than 99 (**799) is not possible but used! \n";
518
+                    }
445 519
 
446 520
                     $quickdial = $value;
447 521
                   }
@@ -451,23 +525,38 @@  discard block
 block discarded – undo
451 525
 
452 526
                 // find out priority
453 527
                 if(in_array("pref", $typearr_lower))
454
-                  $prio = 1;
528
+                {
529
+                                  $prio = 1;
530
+                }
455 531
 
456 532
                 // set the proper type
457 533
                 if(in_array("cell", $typearr_lower))
458
-                  $type = "mobile";
534
+                {
535
+                                  $type = "mobile";
536
+                }
459 537
                 elseif(in_array("home", $typearr_lower))
460
-                  $type = "home";
538
+                {
539
+                                  $type = "home";
540
+                }
461 541
                 elseif(in_array("fax", $typearr_lower))
462
-                  $type = "fax_work";
542
+                {
543
+                                  $type = "fax_work";
544
+                }
463 545
                 elseif(in_array("work", $typearr_lower))
464
-                  $type = "work";
546
+                {
547
+                                  $type = "work";
548
+                }
465 549
                 elseif(in_array("other", $typearr_lower))
466
-                  $type = "other";
550
+                {
551
+                                  $type = "other";
552
+                }
467 553
                 elseif(in_array("dom", $typearr_lower))
468
-                  $type = "other";
469
-                else
470
-                  continue;
554
+                {
555
+                                  $type = "other";
556
+                }
557
+                else {
558
+                                  continue;
559
+                }
471 560
               }
472 561
               $phone_no[] = array("type"=>$type, "prio"=>$prio, "quickdial"=>$quickdial, "value" => $this->_clear_phone_number($phone_number));
473 562
             }
@@ -487,13 +576,20 @@  discard block
 block discarded – undo
487 576
                   $email = $e['value'];
488 577
                   $typearr_lower = unserialize(strtolower(serialize($e['type'])));
489 578
                   if(in_array("work", $typearr_lower))
490
-                    $type_email = "work";
579
+                  {
580
+                                      $type_email = "work";
581
+                  }
491 582
                   elseif(in_array("home", $typearr_lower))
492
-                    $type_email = "home";
583
+                  {
584
+                                      $type_email = "home";
585
+                  }
493 586
                   elseif(in_array("other", $typearr_lower))
494
-                    $type_email = "other";
495
-                  else
496
-                    continue;
587
+                  {
588
+                                      $type_email = "other";
589
+                  }
590
+                  else {
591
+                                      continue;
592
+                  }
497 593
                 }
498 594
 
499 595
                 // DEBUG: print out the email address on the console
@@ -521,7 +617,9 @@  discard block
 block discarded – undo
521 617
   public function build_fb_xml()
522 618
   {
523 619
     if(empty($this->entries))
524
-      throw new Exception('No entries available! Call get_carddav_entries or set $this->entries manually!');
620
+    {
621
+          throw new Exception('No entries available! Call get_carddav_entries or set $this->entries manually!');
622
+    }
525 623
 
526 624
     // create FB XML in utf-8 format
527 625
     $root = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><phonebooks><phonebook></phonebook></phonebooks>');
@@ -560,7 +658,9 @@  discard block
 block discarded – undo
560 658
 
561 659
       // output a warning if no telephone number was found
562 660
       if($id == 0)
563
-        print "  WARNING: no phone entry found. VCard will be ignored." . PHP_EOL;
661
+      {
662
+              print "  WARNING: no phone entry found. VCard will be ignored." . PHP_EOL;
663
+      }
564 664
 
565 665
       // email: put the email addresses into the fritzbox xml file
566 666
       $email = $contact->addChild("services");
@@ -610,8 +710,9 @@  discard block
 block discarded – undo
610 710
 
611 711
             print "  Added photo: " . basename($photo_file) . PHP_EOL;
612 712
           }
613
-          else
614
-           print "  WARNING: Only jpg contact photos are currently supported." . PHP_EOL;
713
+          else {
714
+                     print "  WARNING: Only jpg contact photos are currently supported." . PHP_EOL;
715
+          }
615 716
         }
616 717
         elseif(substr($entry['photo_data'][0], 0, 4) == 'http')
617 718
         {
@@ -620,8 +721,9 @@  discard block
 block discarded – undo
620 721
 
621 722
           print "  Added photo: " . $entry['photo_data'][0] . PHP_EOL;
622 723
         }
623
-        else
624
-          print "  WARNING: Only VCard embedded photo data or a reference URL is currently supported." . PHP_EOL;
724
+        else {
725
+                  print "  WARNING: Only VCard embedded photo data or a reference URL is currently supported." . PHP_EOL;
726
+        }
625 727
       }
626 728
 
627 729
       $contact->addChild("services");
@@ -630,7 +732,9 @@  discard block
 block discarded – undo
630 732
     }
631 733
 
632 734
     if($root->asXML() !== false)
633
-      $this->fbxml = $root->asXML();
735
+    {
736
+          $this->fbxml = $root->asXML();
737
+    }
634 738
     else
635 739
     {
636 740
       print "  ERROR: created XML data isn't well-formed." . PHP_EOL;
@@ -647,19 +751,27 @@  discard block
 block discarded – undo
647 751
   public function _concat($text1, $text2)
648 752
   {
649 753
     if($text1 == '')
650
-      return $text2;
754
+    {
755
+          return $text2;
756
+    }
651 757
     elseif($text2 == '')
652
-      return $text1;
653
-    else
654
-      return $text1 . ", " . $text2;
758
+    {
759
+          return $text1;
760
+    }
761
+    else {
762
+          return $text1 . ", " . $text2;
763
+    }
655 764
   }
656 765
 
657 766
   public function _parse_fb_result($text)
658 767
   {
659 768
     if(preg_match("/\<h2\>([^\<]+)\<\/h2\>/", $text, $matches) == 1 && !empty($matches))
660
-      return $matches[1];
661
-    else
662
-      return "Error while uploading xml to fritzbox";
769
+    {
770
+          return $matches[1];
771
+    }
772
+    else {
773
+          return "Error while uploading xml to fritzbox";
774
+    }
663 775
   }
664 776
 
665 777
   public function upload_to_fb()
@@ -681,15 +793,17 @@  discard block
 block discarded – undo
681 793
 	  	$newphonebhash = md5(preg_replace("/<mod_time>(\\d{10})/","",file_get_contents($this->config['output_file'],'r'),-1,$debugnewtsreplace));
682 794
 	  	print " INFO: Compare old and new phonebook file versions." . PHP_EOL . " INFO: old version: " . $oldphonebhash . PHP_EOL . " INFO: new version: " . $newphonebhash . PHP_EOL;
683 795
 	  	if($oldphonebhash === $newphonebhash)
684
-      	{
796
+	  	{
685 797
       	print " INFO: Same versions ==> No changes in phonebook or images" . PHP_EOL . " EXIT: No need to upload phonebook to the FRITZ!Box.". PHP_EOL;
686 798
       	return 0;
687 799
       	}
688
-      	else
689
-      	print " INFO: Different versions ==> Changes in phonebook." . PHP_EOL . " INFO: Changes dedected! Continue with upload." . PHP_EOL;
800
+      	else {
801
+      	      	print " INFO: Different versions ==> Changes in phonebook." . PHP_EOL . " INFO: Changes dedected! Continue with upload." . PHP_EOL;
802
+      	}
690 803
       }
691
-	  else
692
-      return 0;  
804
+      else {
805
+	        return 0;
806
+	  }
693 807
     }
694 808
     // now we upload the photo jpgs first being stored in the
695 809
     // temp directory.
@@ -759,12 +873,16 @@  discard block
 block discarded – undo
759 873
 
760 874
                   ftp_pasv($conn_id, true);
761 875
                   if(!ftp_put($conn_id, $remote_path . "/" . $file, $fileinfo->getPathname(), FTP_BINARY))
762
-                    print " ERROR: while uploading file " . $fileinfo->getFilename() . PHP_EOL;
763
-                  else
764
-                    print " ok." . PHP_EOL;
876
+                  {
877
+                                      print " ERROR: while uploading file " . $fileinfo->getFilename() . PHP_EOL;
878
+                  }
879
+                  else {
880
+                                      print " ok." . PHP_EOL;
881
+                  }
882
+                }
883
+                else {
884
+                                  print " ok." . PHP_EOL;
765 885
                 }
766
-                else
767
-                  print " ok." . PHP_EOL;
768 886
 
769 887
                 // cleanup old files
770 888
                 foreach($all_existing_files as $existing_file)
@@ -776,20 +894,23 @@  discard block
 block discarded – undo
776 894
                   }
777 895
                 }
778 896
               }
779
-              else
780
-                print " already exists." . PHP_EOL;
897
+              else {
898
+                              print " already exists." . PHP_EOL;
899
+              }
781 900
             }
782 901
           }
783 902
         }
784 903
       }
785
-      else
786
-        print " ERROR: couldn't login to FTP-server '" . $ftp_server . "' with provided username/password settings." . PHP_EOL;
904
+      else {
905
+              print " ERROR: couldn't login to FTP-server '" . $ftp_server . "' with provided username/password settings." . PHP_EOL;
906
+      }
787 907
 
788 908
       // close ftp connection
789 909
       ftp_close($conn_id);
790 910
     }
791
-    else
792
-      print " ERROR: couldn't connect to FTP server '" . $ftp_server . "'." . PHP_EOL;
911
+    else {
912
+          print " ERROR: couldn't connect to FTP server '" . $ftp_server . "'." . PHP_EOL;
913
+    }
793 914
     
794 915
     // lets post the phonebook xml to the FRITZ!Box
795 916
     print " Uploading Phonebook XML to " . $this->config['fritzbox_ip'] . PHP_EOL;
Please login to merge, or discard this patch.