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.
Completed
Branch master (5226a4)
by Jens
02:42
created
carddav2fb.php 1 patch
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 
28 28
 // check for the minimum php version
29 29
 $php_min_version = '5.3.6';
30
-if(version_compare(PHP_VERSION, $php_min_version) < 0)
30
+if (version_compare(PHP_VERSION, $php_min_version) < 0)
31 31
 {
32
-  print 'ERROR: PHP version '.$php_min_version.' is required. Found version: ' . PHP_VERSION . PHP_EOL;
32
+  print 'ERROR: PHP version ' . $php_min_version . ' is required. Found version: ' . PHP_VERSION . PHP_EOL;
33 33
   exit(1);
34 34
 }
35 35
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 require_once('lib/vCard-parser/vCard.php');
38 38
 require_once('lib/fritzbox_api_php/fritzbox_api.class.php');
39 39
 
40
-if($argc == 2)
40
+if ($argc == 2)
41 41
   $config_file_name = $argv[1];
42 42
 else
43 43
   $config_file_name = __DIR__ . '/config.php';
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 $config['build_photos'] = true;
60 60
 $config['quickdial_keyword'] = 'Quickdial:';
61 61
 
62
-if(is_file($config_file_name))
62
+if (is_file($config_file_name))
63 63
   require($config_file_name);
64 64
 else
65 65
 {
66
-  print 'ERROR: No '.$config_file_name.' found, please take a look at config.example.php and create a '.$config_file_name.' file!'.PHP_EOL;
66
+  print 'ERROR: No ' . $config_file_name . ' found, please take a look at config.example.php and create a ' . $config_file_name . ' file!' . PHP_EOL;
67 67
   exit(1);
68 68
 }
69 69
 
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
   }
120 120
 
121 121
   // Source: https://php.net/manual/de/function.tempnam.php#61436
122
-  public function mktemp($dir, $prefix='', $mode=0700)
122
+  public function mktemp($dir, $prefix = '', $mode = 0700)
123 123
   {
124
-    if(substr($dir, -1) != '/')
124
+    if (substr($dir, -1) != '/')
125 125
       $dir .= '/';
126 126
 
127 127
     do
128 128
     {
129
-      $path = $dir.$prefix.mt_rand(0, 9999999);
129
+      $path = $dir . $prefix . mt_rand(0, 9999999);
130 130
     }
131 131
     while (!mkdir($path, $mode));
132 132
 
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
 
136 136
   public function rmtemp($dir)
137 137
   {
138
-    if(is_dir($dir))
138
+    if (is_dir($dir))
139 139
     {
140 140
       $objects = scandir($dir);
141
-      foreach($objects as $object)
141
+      foreach ($objects as $object)
142 142
       {
143
-        if($object != "." && $object != "..")
143
+        if ($object != "." && $object != "..")
144 144
         {
145
-          if(filetype($dir."/".$object) == "dir")
146
-            rrmdir($dir."/".$object); else unlink($dir."/".$object);
145
+          if (filetype($dir . "/" . $object) == "dir")
146
+            rrmdir($dir . "/" . $object); else unlink($dir . "/" . $object);
147 147
         }
148 148
       }
149 149
       reset($objects);
@@ -156,21 +156,21 @@  discard block
 block discarded – undo
156 156
     try
157 157
     {
158 158
       // Check if there are valid base64 characters
159
-      if(!preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $str))
159
+      if (!preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $str))
160 160
         return false;
161 161
 
162 162
       // Decode the string in strict mode and check the results
163 163
       $decoded = base64_decode($str, true);
164
-      if($decoded === false)
164
+      if ($decoded === false)
165 165
         return false;
166 166
 
167 167
       // Encode the string again
168
-      if(base64_encode($decoded) === $str)
168
+      if (base64_encode($decoded) === $str)
169 169
         return true;
170 170
       else
171 171
         return false;
172 172
     }
173
-    catch(Exception $e)
173
+    catch (Exception $e)
174 174
     {
175 175
       // If exception is caught, then it is not a base64 encoded string
176 176
       return false;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     $imgseqfname = 1;
200 200
     $snum = 0;
201 201
 
202
-    foreach($this->config['carddav'] as $conf)
202
+    foreach ($this->config['carddav'] as $conf)
203 203
     {
204 204
       print " [" . $snum . "]: " . $conf['url'] . " ";
205 205
       $carddav = new CardDavPHP\CardDavBackend($conf['url']);
@@ -207,23 +207,23 @@  discard block
 block discarded – undo
207 207
 
208 208
       // set the vcard extension in case the user
209 209
       // defined it in the config
210
-      if(isset($conf['extension']))
210
+      if (isset($conf['extension']))
211 211
         $carddav->setVcardExtension($conf['extension']);
212 212
 
213 213
       // retrieve data from the CardDAV server now
214
-      $xmldata =  $carddav->get();
214
+      $xmldata = $carddav->get();
215 215
 
216 216
       // identify if we received UTF-8 encoded data from the
217 217
       // CardDAV server and if not reencode it since the FRITZ!Box
218 218
       // requires UTF-8 encoded data
219
-      if(iconv('utf-8', 'utf-8//IGNORE', $xmldata) != $xmldata)
219
+      if (iconv('utf-8', 'utf-8//IGNORE', $xmldata) != $xmldata)
220 220
         $xmldata = utf8_encode($xmldata);
221 221
 
222 222
       // read raw_vcard data from xml response
223 223
       $raw_vcards = array();
224 224
       $xmlvcard = new SimpleXMLElement($xmldata);
225 225
 
226
-      foreach($xmlvcard->element as $vcard_element)
226
+      foreach ($xmlvcard->element as $vcard_element)
227 227
       {
228 228
         $id = $vcard_element->id->__toString();
229 229
         $value = (string)$vcard_element->vcard->__toString();
@@ -235,14 +235,14 @@  discard block
 block discarded – undo
235 235
       // parse raw_vcards
236 236
       $result = array();
237 237
       $quick_dial_arr = array();
238
-      foreach($raw_vcards as $v)
238
+      foreach ($raw_vcards as $v)
239 239
       {
240 240
         $vcard_obj = new vCard(false, $v);
241 241
         $name_arr = null;
242
-        if(isset($vcard_obj->n[0]))
242
+        if (isset($vcard_obj->n[0]))
243 243
           $name_arr = $vcard_obj->n[0];
244 244
         $org_arr = null;
245
-        if(isset($vcard_obj->org[0]))
245
+        if (isset($vcard_obj->org[0]))
246 246
           $org_arr = $vcard_obj->org[0];
247 247
         $addnames = '';
248 248
         $prefix = '';
@@ -252,16 +252,16 @@  discard block
 block discarded – undo
252 252
         $lastname = '';
253 253
 
254 254
         // Build name Parts if existing ans switch to true in config
255
-        if(isset($name_arr['prefixes']) AND $this->config['prefix'])
255
+        if (isset($name_arr['prefixes']) AND $this->config['prefix'])
256 256
           $prefix = trim($name_arr['prefixes']);
257 257
 
258
-        if(isset($name_arr['suffixes']) AND $this->config['suffix'])
258
+        if (isset($name_arr['suffixes']) AND $this->config['suffix'])
259 259
           $suffix = trim($name_arr['suffixes']);
260 260
 
261
-        if(isset($name_arr['additionalnames']) AND $this->config['addnames'])
261
+        if (isset($name_arr['additionalnames']) AND $this->config['addnames'])
262 262
           $addnames = trim($name_arr['additionalnames']);
263 263
 
264
-        if(isset($org_arr['name']) AND $this->config['orgname'])
264
+        if (isset($org_arr['name']) AND $this->config['orgname'])
265 265
           $orgname = trim($org_arr['name']);
266 266
 
267 267
         $firstname = trim($name_arr['firstname']);
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
         $format = $this->config['fullname_format'];
282 282
 
283 283
         // Prefix
284
-        if(!empty($prefix))
284
+        if (!empty($prefix))
285 285
           $name .= $prefix;
286 286
 
287
-        if($format == 0)
287
+        if ($format == 0)
288 288
         {
289 289
           // Lastname
290
-          if(!empty($name) AND !empty($lastname))
290
+          if (!empty($name) AND !empty($lastname))
291 291
             $name .= ' ' . $lastname;
292 292
           else
293 293
             $name .= $lastname;
@@ -295,25 +295,25 @@  discard block
 block discarded – undo
295 295
         else
296 296
         {
297 297
           // Firstname
298
-          if(!empty($name) AND !empty($firstname))
298
+          if (!empty($name) AND !empty($firstname))
299 299
             $name .= ' ' . $firstname;
300 300
           else
301 301
             $name .= $firstname;
302 302
         }
303 303
 
304
-        if($format == 2)
304
+        if ($format == 2)
305 305
         {
306 306
           // AdditionalNames
307
-          if(!empty($name) AND !empty($addnames))
307
+          if (!empty($name) AND !empty($addnames))
308 308
             $name .= ' ' . $addnames;
309 309
           else
310 310
             $name .= $addnames;
311 311
         }
312 312
 
313
-        if($format == 0)
313
+        if ($format == 0)
314 314
         {
315 315
           // Firstname
316
-          if(!empty($name) AND !empty($firstname))
316
+          if (!empty($name) AND !empty($firstname))
317 317
             $name .= ', ' . $firstname;
318 318
           else
319 319
             $name .= $firstname;
@@ -321,29 +321,29 @@  discard block
 block discarded – undo
321 321
         else
322 322
         {
323 323
           // Lastname
324
-          if(!empty($name) AND !empty($lastname))
324
+          if (!empty($name) AND !empty($lastname))
325 325
             $name .= ' ' . $lastname;
326 326
           else
327 327
             $name .= $lastname;
328 328
         }
329 329
 
330
-        if($format != 2)
330
+        if ($format != 2)
331 331
         {
332 332
           // AdditionalNames
333
-          if(!empty($name) AND !empty($addnames))
333
+          if (!empty($name) AND !empty($addnames))
334 334
             $name .= ' ' . $addnames;
335 335
           else
336 336
             $name .= $addnames;
337 337
         }
338 338
 
339 339
         // Suffix
340
-        if(!empty($name) AND !empty($suffix))
340
+        if (!empty($name) AND !empty($suffix))
341 341
           $name .= ' ' . $suffix;
342 342
         else
343 343
           $name .= $suffix;
344 344
 
345 345
         // OrgName
346
-        if(!empty($name) AND !empty($orgname))
346
+        if (!empty($name) AND !empty($orgname))
347 347
           $name .= ' (' . $orgname . ')';
348 348
         else
349 349
           $name .= $orgname;
@@ -351,24 +351,24 @@  discard block
 block discarded – undo
351 351
         // make sure to trim whitespaces and double spaces
352 352
         $name = trim(str_replace('  ', ' ', $name));
353 353
 
354
-        if(empty($name))
354
+        if (empty($name))
355 355
         {
356 356
           print '  WARNING: No fullname, lastname or orgname found!';
357 357
           $name = 'UNKNOWN';
358 358
         }
359 359
 
360 360
         // format filename of contact photo; remove special letters, added config option for sequential filnames default is false
361
-        if($vcard_obj->photo)
361
+        if ($vcard_obj->photo)
362 362
         {
363
-          if(isset($this->config['seq_photo_name']) AND $this->config['seq_photo_name'] == true)
363
+          if (isset($this->config['seq_photo_name']) AND $this->config['seq_photo_name'] == true)
364 364
           {
365 365
             $photo = $imgseqfname;
366 366
             $imgseqfname++;
367 367
           }
368 368
           else
369 369
           {
370
-            $photo = str_replace(array(',','&',' ','/','ä','ö','ü','Ä','Ö','Ü','ß','á','à','ó','ò','ú','ù','í','ø'),
371
-            array('','_','_','_','ae','oe','ue','Ae','Oe','Ue','ss','a','a','o','o','u','u','i','oe'),$name);
370
+            $photo = str_replace(array(',', '&', ' ', '/', 'ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß', 'á', 'à', 'ó', 'ò', 'ú', 'ù', 'í', 'ø'),
371
+            array('', '_', '_', '_', 'ae', 'oe', 'ue', 'Ae', 'Oe', 'Ue', 'ss', 'a', 'a', 'o', 'o', 'u', 'u', 'i', 'oe'), $name);
372 372
           }
373 373
         }
374 374
         else
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 
377 377
         // phone
378 378
         $phone_no = array();
379
-        if($vcard_obj->categories)
379
+        if ($vcard_obj->categories)
380 380
           $categories = $vcard_obj->categories[0];
381 381
         else
382 382
           $categories = array();
@@ -385,19 +385,19 @@  discard block
 block discarded – undo
385 385
         $quick_dial_nr = null;
386 386
         
387 387
         // check for quickdial entry
388
-        if(isset($vcard_obj->note[0]))
388
+        if (isset($vcard_obj->note[0]))
389 389
         {
390 390
           $note = $vcard_obj->note[0];
391 391
           $notes = explode($this->config['quickdial_keyword'], $note);
392
-          foreach($notes as $linenr => $linecontent)
392
+          foreach ($notes as $linenr => $linecontent)
393 393
           {
394
-            $found = strrpos($linecontent , ":**7");
395
-            if($found > 0)
394
+            $found = strrpos($linecontent, ":**7");
395
+            if ($found > 0)
396 396
             {
397
-              $pos_qd_start = strrpos($linecontent , ":**7" );
398
-              $quick_dial_for_nr = preg_replace("/[^0-9+]/", "",substr($linecontent , 0, $pos_qd_start));
399
-              $quick_dial_nr = intval(substr($linecontent , $pos_qd_start+4, 3));
400
-              $quick_dial_arr[$quick_dial_for_nr]=$quick_dial_nr;
397
+              $pos_qd_start = strrpos($linecontent, ":**7");
398
+              $quick_dial_for_nr = preg_replace("/[^0-9+]/", "", substr($linecontent, 0, $pos_qd_start));
399
+              $quick_dial_nr = intval(substr($linecontent, $pos_qd_start + 4, 3));
400
+              $quick_dial_arr[$quick_dial_for_nr] = $quick_dial_nr;
401 401
             }
402 402
           }
403 403
         }
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
         $email_add = array();
407 407
         $vip = isset($this->config['group_vip']) && in_array((string)$this->config['group_vip'], $categories);
408 408
 
409
-        if(array_key_exists('group_filter',$this->config))
409
+        if (array_key_exists('group_filter', $this->config))
410 410
         {
411 411
           $add_entry = 0;
412
-          foreach($this->config['group_filter'] as $group_filter)
412
+          foreach ($this->config['group_filter'] as $group_filter)
413 413
           {
414
-            if(in_array($group_filter,$categories))
414
+            if (in_array($group_filter, $categories))
415 415
             {
416 416
               $add_entry = 1;
417 417
               break;
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
         else
422 422
           $add_entry = 1;
423 423
 
424
-        if($add_entry == 1)
424
+        if ($add_entry == 1)
425 425
         {
426
-          foreach($vcard_obj->tel as $t)
426
+          foreach ($vcard_obj->tel as $t)
427 427
           {
428 428
             $prio = 0;
429
-            $quickdial =null;
429
+            $quickdial = null;
430 430
             
431
-            if(!is_array($t) || empty($t['type']))
431
+            if (!is_array($t) || empty($t['type']))
432 432
             {
433 433
               $type = "mobile";
434 434
               $phone_number = $t;
@@ -437,15 +437,15 @@  discard block
 block discarded – undo
437 437
             {
438 438
               $phone_number = $t['value'];
439 439
               
440
-              $phone_number_clean = preg_replace("/[^0-9+]/", "",$phone_number);
441
-              foreach($quick_dial_arr as $qd_phone_nr => $value)
440
+              $phone_number_clean = preg_replace("/[^0-9+]/", "", $phone_number);
441
+              foreach ($quick_dial_arr as $qd_phone_nr => $value)
442 442
               {
443
-                if($qd_phone_nr == $phone_number_clean)
443
+                if ($qd_phone_nr == $phone_number_clean)
444 444
                 {
445 445
                   //Set quickdial
446
-                  if($value == 1)
446
+                  if ($value == 1)
447 447
                     print "\nWARNING: Quickdial value 1 (**701) is not possible but used! \n";
448
-                  elseif($value >= 100)
448
+                  elseif ($value >= 100)
449 449
                     print "\nWARNING: Quickdial value bigger than 99 (**799) is not possible but used! \n";
450 450
 
451 451
                   $quickdial = $value;
@@ -455,34 +455,34 @@  discard block
 block discarded – undo
455 455
               $typearr_lower = unserialize(strtolower(serialize($t['type'])));
456 456
 
457 457
               // find out priority
458
-              if(in_array("pref", $typearr_lower))
458
+              if (in_array("pref", $typearr_lower))
459 459
                 $prio = 1;
460 460
 
461 461
               // set the proper type
462
-              if(in_array("cell", $typearr_lower))
462
+              if (in_array("cell", $typearr_lower))
463 463
                 $type = "mobile";
464
-              elseif(in_array("home", $typearr_lower))
464
+              elseif (in_array("home", $typearr_lower))
465 465
                 $type = "home";
466
-              elseif(in_array("fax", $typearr_lower))
466
+              elseif (in_array("fax", $typearr_lower))
467 467
                 $type = "fax_work";
468
-              elseif(in_array("work", $typearr_lower))
468
+              elseif (in_array("work", $typearr_lower))
469 469
                 $type = "work";
470
-              elseif(in_array("other", $typearr_lower))
470
+              elseif (in_array("other", $typearr_lower))
471 471
                 $type = "other";
472
-              elseif(in_array("dom", $typearr_lower))
472
+              elseif (in_array("dom", $typearr_lower))
473 473
                 $type = "other";
474 474
               else
475 475
                 continue;
476 476
             }
477
-            $phone_no[] =  array("type"=>$type, "prio"=>$prio, "quickdial"=>$quickdial, "value" => $this->_clear_phone_number($phone_number));
477
+            $phone_no[] = array("type"=>$type, "prio"=>$prio, "quickdial"=>$quickdial, "value" => $this->_clear_phone_number($phone_number));
478 478
           }
479 479
 
480 480
           // request email address and type
481
-          if($vcard_obj->email)
481
+          if ($vcard_obj->email)
482 482
           {
483
-            foreach($vcard_obj->email as $e)
483
+            foreach ($vcard_obj->email as $e)
484 484
             {
485
-              if(empty($e['type']))
485
+              if (empty($e['type']))
486 486
               {
487 487
                 $type_email = "work";
488 488
                 $email = $e;
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
               {
492 492
                 $email = $e['value'];
493 493
                 $typearr_lower = unserialize(strtolower(serialize($e['type'])));
494
-                if(in_array("work", $typearr_lower))
494
+                if (in_array("work", $typearr_lower))
495 495
                   $type_email = "work";
496
-                elseif(in_array("home", $typearr_lower))
496
+                elseif (in_array("home", $typearr_lower))
497 497
                   $type_email = "home";
498
-                elseif(in_array("other", $typearr_lower))
498
+                elseif (in_array("other", $typearr_lower))
499 499
                   $type_email = "other";
500 500
                 else
501 501
                   continue;
@@ -524,15 +524,15 @@  discard block
 block discarded – undo
524 524
 
525 525
   public function build_fb_xml()
526 526
   {
527
-    if(empty($this->entries))
527
+    if (empty($this->entries))
528 528
       throw new Exception('No entries available! Call get_carddav_entries or set $this->entries manually!');
529 529
 
530 530
     // create FB XML in utf-8 format
531 531
     $root = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><phonebooks><phonebook></phonebook></phonebooks>');
532 532
     $pb = $root->phonebook;
533
-    $pb->addAttribute("name",$this->config['phonebook_name']);
533
+    $pb->addAttribute("name", $this->config['phonebook_name']);
534 534
 
535
-    foreach($this->entries as $entry)
535
+    foreach ($this->entries as $entry)
536 536
     {
537 537
       $contact = $pb->addChild("contact");
538 538
       $contact->addChild("category", $entry['vip']);
@@ -544,17 +544,17 @@  discard block
 block discarded – undo
544 544
       // telephone: put the phonenumbers into the fritzbox xml file
545 545
       $telephony = $contact->addChild("telephony");
546 546
       $id = 0;
547
-      foreach($entry['telephony'] as $tel)
547
+      foreach ($entry['telephony'] as $tel)
548 548
       {
549 549
         $num = $telephony->addChild("number", $tel['value']);
550 550
         $num->addAttribute("type", $tel['type']);
551
-        $num->addAttribute("vanity","");
551
+        $num->addAttribute("vanity", "");
552 552
         $num->addAttribute("prio", $tel['prio']);
553 553
         $num->addAttribute("id", $id);
554 554
 
555
-        if(isset($tel['quickdial']))
555
+        if (isset($tel['quickdial']))
556 556
         {
557
-          $num->addAttribute("quickdial",$tel['quickdial']);
557
+          $num->addAttribute("quickdial", $tel['quickdial']);
558 558
           print "  Added quickdial: " . $tel['quickdial'] . " for: " . $tel['value'] . " (" . $tel['type'] . ")" . PHP_EOL;
559 559
         }
560 560
 
@@ -563,13 +563,13 @@  discard block
 block discarded – undo
563 563
       }
564 564
 
565 565
       // output a warning if no telephone number was found
566
-      if($id == 0)
566
+      if ($id == 0)
567 567
         print "  WARNING: no phone entry found. VCard will be ignored." . PHP_EOL;
568 568
 
569 569
       // email: put the email addresses into the fritzbox xml file
570 570
       $email = $contact->addChild("services");
571 571
       $id = 0;
572
-      foreach($entry['email'] as $mail)
572
+      foreach ($entry['email'] as $mail)
573 573
       {
574 574
         $mail_adr = $email->addChild("email", $mail['value']);
575 575
         $mail_adr->addAttribute("classifier", $mail['type']);
@@ -580,14 +580,14 @@  discard block
 block discarded – undo
580 580
       }
581 581
 
582 582
       // check for a photo being part of the VCard
583
-      if(($entry['photo']) and ($entry['photo_data']) and (is_array($entry['photo_data'])) and ($entry['photo_data'][0]))
583
+      if (($entry['photo']) and ($entry['photo_data']) and (is_array($entry['photo_data'])) and ($entry['photo_data'][0]))
584 584
       {
585 585
         // check if 'photo_data'[0] is an array as well because then
586 586
         // we have to extract ['value'] and friends.
587
-        if(is_array($entry['photo_data'][0]) and (array_key_exists('value', $entry['photo_data'][0])))
587
+        if (is_array($entry['photo_data'][0]) and (array_key_exists('value', $entry['photo_data'][0])))
588 588
         {
589 589
           // check if photo_data really contains JPEG data
590
-          if((array_key_exists('type', $entry['photo_data'][0])) and (is_array($entry['photo_data'][0]['type'])) and
590
+          if ((array_key_exists('type', $entry['photo_data'][0])) and (is_array($entry['photo_data'][0]['type'])) and
591 591
              ($entry['photo_data'][0]['type'][0] == 'jpeg' or $entry['photo_data'][0]['type'][0] == 'jpg'))
592 592
           {
593 593
             // get photo, rename, base64 convert and save as jpg
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 
598 598
             // check for base64 encoding of the photo data and convert it
599 599
             // accordingly.
600
-            if(((array_key_exists('encoding', $entry['photo_data'][0])) and ($entry['photo_data'][0]['encoding'] == 'b')) or $this->is_base64($photo_data))
600
+            if (((array_key_exists('encoding', $entry['photo_data'][0])) and ($entry['photo_data'][0]['encoding'] == 'b')) or $this->is_base64($photo_data))
601 601
             {
602 602
               file_put_contents($photo_file . ".b64", $photo_data);
603 603
               $this->base64_to_jpeg($photo_file . ".b64", $photo_file);
@@ -610,14 +610,14 @@  discard block
 block discarded – undo
610 610
             }
611 611
 
612 612
             // add contact photo to xml
613
-            $person->addChild("imageURL", $this->config['fritzbox_path'].$this->config['usb_disk']."FRITZ/fonpix/".basename($photo_file));
613
+            $person->addChild("imageURL", $this->config['fritzbox_path'] . $this->config['usb_disk'] . "FRITZ/fonpix/" . basename($photo_file));
614 614
 
615 615
             print "  Added photo: " . basename($photo_file) . PHP_EOL;
616 616
           }
617 617
           else
618 618
            print "  WARNING: Only jpg contact photos are currently supported." . PHP_EOL;
619 619
         }
620
-        elseif(substr($entry['photo_data'][0], 0, 4) == 'http')
620
+        elseif (substr($entry['photo_data'][0], 0, 4) == 'http')
621 621
         {
622 622
           // add contact photo to xml
623 623
           $person->addChild("imageURL", $entry['photo_data'][0]);
@@ -642,20 +642,20 @@  discard block
 block discarded – undo
642 642
     return $text;
643 643
   }
644 644
 
645
-  public function _concat ($text1,$text2)
645
+  public function _concat($text1, $text2)
646 646
   {
647
-    if($text1 == '')
647
+    if ($text1 == '')
648 648
       return $text2;
649
-    elseif($text2 == '')
649
+    elseif ($text2 == '')
650 650
       return $text1;
651 651
     else
652
-      return $text1.", ".$text2;
652
+      return $text1 . ", " . $text2;
653 653
   }
654 654
 
655 655
   public function _parse_fb_result($text)
656 656
   {
657 657
     preg_match("/\<h2\>([^\<]+)\<\/h2\>/", $text, $matches);
658
-    if($matches)
658
+    if ($matches)
659 659
       return $matches[1];
660 660
     else
661 661
       return "Error while uploading xml to fritzbox";
@@ -664,10 +664,10 @@  discard block
 block discarded – undo
664 664
   public function upload_to_fb()
665 665
   {
666 666
     // if the user wants to save the xml to a separate file, we do so now
667
-    if(array_key_exists('output_file',$this->config))
667
+    if (array_key_exists('output_file', $this->config))
668 668
     {
669 669
       $output = fopen($this->config['output_file'], 'w');
670
-      if($output)
670
+      if ($output)
671 671
       {
672 672
         fwrite($output, $this->fbxml);
673 673
         fclose($output);
@@ -682,24 +682,24 @@  discard block
 block discarded – undo
682 682
     // perform an ftps-connection to copy over the photos to a specified directory
683 683
     $ftp_server = $this->config['fritzbox_ip_ftp'];
684 684
     $conn_id = ftp_ssl_connect($ftp_server);
685
-    if($conn_id == false)
685
+    if ($conn_id == false)
686 686
     {
687 687
       print " WARNING: Secure connection to FTP-server '" . $ftp_server . "' failed, retrying without SSL."
688 688
       $conn_id = ftp_connect($ftp_server);
689 689
     }
690 690
 
691
-    if($conn_id != false)
691
+    if ($conn_id != false)
692 692
     {
693 693
       ftp_set_option($conn_id, FTP_TIMEOUT_SEC, 60);
694 694
       $login_result = ftp_login($conn_id, $this->config['fritzbox_user'], $this->config['fritzbox_pw']);
695
-      if($login_result == true)
695
+      if ($login_result == true)
696 696
       {
697 697
         ftp_pasv($conn_id, true);
698 698
 
699 699
         // create remote photo path on FRITZ!Box if it doesn't exist
700
-        $remote_path = $this->config['usb_disk']."/FRITZ/fonpix";
700
+        $remote_path = $this->config['usb_disk'] . "/FRITZ/fonpix";
701 701
         $all_existing_files = ftp_nlist($conn_id, $remote_path);
702
-        if($all_existing_files == false)
702
+        if ($all_existing_files == false)
703 703
         {
704 704
           ftp_mkdir($conn_id, $remote_path);
705 705
           $all_existing_files = array();
@@ -707,43 +707,43 @@  discard block
 block discarded – undo
707 707
 
708 708
         // now iterate through all jpg files in tempdir and upload them if necessary
709 709
         $dir = new DirectoryIterator($this->tmpdir);
710
-        foreach($dir as $fileinfo)
710
+        foreach ($dir as $fileinfo)
711 711
         {
712
-          if(!$fileinfo->isDot())
712
+          if (!$fileinfo->isDot())
713 713
           {
714
-            if($fileinfo->getExtension() == "jpg")
714
+            if ($fileinfo->getExtension() == "jpg")
715 715
             {
716 716
               $file = $fileinfo->getFilename();
717 717
 
718 718
               print " FTP-Upload '" . $file . "'...";
719
-              if(!in_array($remote_path . "/" . $file, $all_existing_files))
719
+              if (!in_array($remote_path . "/" . $file, $all_existing_files))
720 720
               {
721
-                if(!ftp_put($conn_id, $remote_path . "/" . $file, $fileinfo->getPathname(), FTP_BINARY))
721
+                if (!ftp_put($conn_id, $remote_path . "/" . $file, $fileinfo->getPathname(), FTP_BINARY))
722 722
                 {
723 723
                   // retry when a fault occurs.
724 724
                   print " retrying... ";
725 725
                   $conn_id = ftp_ssl_connect($ftp_server);
726
-                  if($conn_id == false)
726
+                  if ($conn_id == false)
727 727
                   {
728 728
                     print " WARNING: Secure re-connection to FTP-server '" . $ftp_server . "' failed, retrying without SSL."
729 729
                     $conn_id = ftp_connect($ftp_server);
730 730
                   }
731 731
 
732
-                  if($conn_id == false)
732
+                  if ($conn_id == false)
733 733
                   {
734 734
                     print " ERROR: couldn't re-connect to FTP server '" . $ftp_server . "', abortіng."
735 735
                     break;
736 736
                   }
737 737
 
738 738
                   $login_result = ftp_login($conn_id, $this->config['fritzbox_user'], $this->config['fritzbox_pw']);
739
-                  if($login_result == false)
739
+                  if ($login_result == false)
740 740
                   {
741 741
                     print " ERROR: couldn't re-login to FTP-server '" . $ftp_server . "' with provided username/password settings."
742 742
                     break;
743 743
                   }
744 744
 
745 745
                   ftp_pasv($conn_id, true);
746
-                  if(!ftp_put($conn_id, $remote_path . "/" . $file, $fileinfo->getPathname(), FTP_BINARY))
746
+                  if (!ftp_put($conn_id, $remote_path . "/" . $file, $fileinfo->getPathname(), FTP_BINARY))
747 747
                     print " ERROR: while uploading file " . $fileinfo->getFilename() . PHP_EOL;
748 748
                   else
749 749
                     print " ok." . PHP_EOL;
@@ -752,9 +752,9 @@  discard block
 block discarded – undo
752 752
                   print " ok." . PHP_EOL;
753 753
 
754 754
                 // cleanup old files
755
-                foreach($all_existing_files as $existing_file)
755
+                foreach ($all_existing_files as $existing_file)
756 756
                 {
757
-                  if(strpos($existing_file, $remote_path."/".substr($file, 0, -10)) !== false)
757
+                  if (strpos($existing_file, $remote_path . "/" . substr($file, 0, -10)) !== false)
758 758
                   {
759 759
                     print " FTP-Delete: " . $existing_file . PHP_EOL;
760 760
                     ftp_delete($conn_id, $remote_path . "/" . basename($existing_file));
@@ -778,14 +778,14 @@  discard block
 block discarded – undo
778 778
 
779 779
     // in case numeric IP is given, try to resolve to hostname. Otherwise Fritzbox may decline login, because it is determine to be (prohibited) remote access
780 780
     $hostname = $this->config['fritzbox_ip'];
781
-    if(filter_var($hostname, FILTER_VALIDATE_IP))
781
+    if (filter_var($hostname, FILTER_VALIDATE_IP))
782 782
     {
783 783
       $hostname = gethostbyaddr($hostname);
784
-      if($hostname ==  $this->config['fritzbox_ip'])
785
-        print " WARNING: Unable to get hostname for IP address (". $this->config['fritzbox_ip'] .") <" . $hostname . "<" . PHP_EOL;
784
+      if ($hostname == $this->config['fritzbox_ip'])
785
+        print " WARNING: Unable to get hostname for IP address (" . $this->config['fritzbox_ip'] . ") <" . $hostname . "<" . PHP_EOL;
786 786
       else
787 787
       {
788
-        print " INFO: Given IP address (". $this->config['fritzbox_ip'] .") has hostname ". $hostname . "." . PHP_EOL;
788
+        print " INFO: Given IP address (" . $this->config['fritzbox_ip'] . ") has hostname " . $hostname . "." . PHP_EOL;
789 789
         $this->config['fritzbox_ip'] = $hostname;
790 790
       }
791 791
     }
@@ -810,15 +810,15 @@  discard block
 block discarded – undo
810 810
        )
811 811
       );
812 812
 
813
-      $raw_result =  $fritz->doPostFile($formfields, $filefileds);   // send the command
813
+      $raw_result = $fritz->doPostFile($formfields, $filefileds); // send the command
814 814
       $msg = $this->_parse_fb_result($raw_result);
815
-      $fritz = null;  // destroy the object to log out
815
+      $fritz = null; // destroy the object to log out
816 816
 
817 817
       print "  FRITZ!Box returned message: '" . $msg . "'" . PHP_EOL;
818 818
     }
819
-    catch(Exception $e)
819
+    catch (Exception $e)
820 820
     {
821
-      print "  ERROR: " . $e->getMessage() . PHP_EOL;     // show the error message in anything failed
821
+      print "  ERROR: " . $e->getMessage() . PHP_EOL; // show the error message in anything failed
822 822
     }
823 823
   }
824 824
 }
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_guestlan_on_off.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
   $message = date('Y-m-d H:i') . ' ';
24 24
 
25 25
   // handle the CLI arguments or give a help message
26
-  if (isset($argv[1]) && ($argv[1] == 0 || $argv[1] == 1) )
26
+  if (isset($argv[1]) && ($argv[1] == 0 || $argv[1] == 1))
27 27
   {
28 28
     $mode = (bool)$argv[1];
29 29
   }
30 30
   else
31 31
   {
32
-    if ( $fritz->config->getItem('logging') == 'console' )
32
+    if ($fritz->config->getItem('logging') == 'console')
33 33
     {
34 34
       echo '
35 35
   Enables or disables the LAN4 guest access of a Fritz!Box
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
   
62 62
   // read time_server_activ setting
63 63
   preg_match('@name="time_server_activ"[^>]+(checked)[^>]*@', $output, $matches);
64
-  if ( isset($matches[1]) )
64
+  if (isset($matches[1]))
65 65
   {
66 66
     $formfields['time_server_activ'] = 'on';
67 67
   }
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
   $formfields['time_server'] = isset($matches[1]) ? $matches[1] : '0.europe.pool.ntp.org';
71 71
   // read other_prefix_allowed setting
72 72
   preg_match('@name="other_prefix_allowed"[^>]+(checked)[^>]*@', $output, $matches);
73
-  if ( isset($matches[1]) )
73
+  if (isset($matches[1]))
74 74
   {
75 75
     $formfields['other_prefix_allowed'] = 'on';
76 76
   }
77 77
   // read dnsv6_server_activ setting
78 78
   preg_match('@name="dnsv6_server_activ"[^>]+(checked)[^>]*@', $output, $matches);
79
-  if ( isset($matches[1]) )
79
+  if (isset($matches[1]))
80 80
   {
81 81
     $formfields['dnsv6_server_activ'] = 'on';
82 82
   }
83 83
   
84 84
   // set new given setting
85
-  if ( $mode == true )
85
+  if ($mode == true)
86 86
   {
87 87
     $formfields['guest_enabled'] = 'on';
88 88
   }
@@ -92,19 +92,19 @@  discard block
 block discarded – undo
92 92
   $output = $fritz->doPostForm($formfields);
93 93
 
94 94
   preg_match('@name="guest_enabled"[^>]+(checked)[^>]*@', $output, $matches);
95
-  if ( isset($matches[1]) && $mode == true )
95
+  if (isset($matches[1]) && $mode == true)
96 96
   {
97 97
 		$message .= 'LAN4 guest access is now active.';
98 98
   }
99
-  else if ( !isset($matches[1]) && $mode == false )
99
+  else if (!isset($matches[1]) && $mode == false)
100 100
   {
101 101
     $message .= 'LAN4 guest access is now inactive.';
102 102
   }
103
-  else if ( isset($matches[1]) && $mode == false )
103
+  else if (isset($matches[1]) && $mode == false)
104 104
   {
105 105
     $message .= 'ERROR: LAN4 guest access status change failed, should be inactive, but is still active.';
106 106
   }
107
-  else if ( !isset($matches[1]) && $mode == true )
107
+  else if (!isset($matches[1]) && $mode == true)
108 108
   {
109 109
     $message .= 'ERROR: LAN4 guest access status change failed, should be active, but is still inactive.';
110 110
   }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 }
116 116
 
117 117
 // log the result
118
-if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' )
118
+if (isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api')
119 119
 {
120 120
   $fritz->logMessage($message);
121 121
 }
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_api.class.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -63,39 +63,39 @@  discard block
 block discarded – undo
63 63
     * 
64 64
     * @access public
65 65
     */
66
-  public function __construct($password = false,$user_name = false,$fritzbox_ip = 'fritz.box',$force_local_login = false)
66
+  public function __construct($password = false, $user_name = false, $fritzbox_ip = 'fritz.box', $force_local_login = false)
67 67
   {
68 68
 	// init the config object
69 69
 	$this->config = new fritzbox_api_config();
70 70
     
71 71
 	// try autoloading the config
72
-	if (file_exists(__DIR__ . '/fritzbox_user.conf.php') && is_readable(__DIR__ . '/fritzbox_user.conf.php') ) {
72
+	if (file_exists(__DIR__ . '/fritzbox_user.conf.php') && is_readable(__DIR__ . '/fritzbox_user.conf.php')) {
73 73
 		require_once(__DIR__ . '/fritzbox_user.conf.php');
74 74
 	}
75 75
 
76 76
 	// set FRITZ!Box-IP and URL
77
-	$this->config->setItem('fritzbox_ip',$fritzbox_ip);
77
+	$this->config->setItem('fritzbox_ip', $fritzbox_ip);
78 78
 
79 79
 	// check if login on local network (fritz.box) or via a dynamic DNS-host
80 80
 	if ($fritzbox_ip != 'fritz.box' && !$force_local_login) {
81
-		$this->config->setItem('enable_remote_config',true);
82
-		$this->config->setItem('remote_config_user',$user_name);
83
-		$this->config->setItem('remote_config_password',$password);
84
-		$this->config->setItem('fritzbox_url', 'https://'.$this->config->getItem('fritzbox_ip'));
81
+		$this->config->setItem('enable_remote_config', true);
82
+		$this->config->setItem('remote_config_user', $user_name);
83
+		$this->config->setItem('remote_config_password', $password);
84
+		$this->config->setItem('fritzbox_url', 'https://' . $this->config->getItem('fritzbox_ip'));
85 85
 	} else {
86
-		$this->config->setItem('enable_remote_config',false);
87
-		if($user_name != false){
88
-			$this->config->setItem('username',$user_name);
86
+		$this->config->setItem('enable_remote_config', false);
87
+		if ($user_name != false) {
88
+			$this->config->setItem('username', $user_name);
89 89
 		}
90
-		if($password != false){
91
-			$this->config->setItem('password',$password);
90
+		if ($password != false) {
91
+			$this->config->setItem('password', $password);
92 92
 		}
93 93
 		$this->config->setItem('fritzbox_url', 'http://' . $this->config->getItem('fritzbox_ip'));
94 94
 	}
95 95
 
96 96
 	// 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') ){
97
+	if ($this->config->getItem('enable_remote_config') === true) {
98
+		if (!$this->config->getItem('remote_config_user') || !$this->config->getItem('remote_config_password')) {
99 99
 		  $this->error('ERROR: Remote config mode enabled, but no username or no password provided');
100 100
 		}
101 101
 	}
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
   {
130 130
     $ch = curl_init();
131 131
 
132
-    if ( isset($formfields['getpage']) && strpos($formfields['getpage'], '.lua') > 0 )
132
+    if (isset($formfields['getpage']) && strpos($formfields['getpage'], '.lua') > 0)
133 133
     {
134 134
       curl_setopt($ch, CURLOPT_URL, $this->config->getItem('fritzbox_url') . $formfields['getpage'] . '?sid=' . $this->sid);
135 135
       unset($formfields['getpage']);
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
     }
146 146
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
147 147
     curl_setopt($ch, CURLOPT_POST, 1);
148
-    if ( $this->config->getItem('enable_remote_config') == true )
148
+    if ($this->config->getItem('enable_remote_config') == true)
149 149
     {
150 150
 		// 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'),":")){
151
+		if (strpos($this->config->getItem('fritzbox_ip'), ":")) {
152 152
 			$ssl_cert_fritzbox = explode(":", $this->config->getItem('fritzbox_ip'));
153 153
 			$ssl_cert_fritzbox = $ssl_cert_fritzbox[0];
154 154
 		} else {
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 		// set SSL-options and path to certificate
159 159
 		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 2);
160 160
 		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
161
-		curl_setopt($ch, CURLOPT_CAINFO, '/etc/ssl/certs/'.$ssl_cert_fritzbox.'.pem');
161
+		curl_setopt($ch, CURLOPT_CAINFO, '/etc/ssl/certs/' . $ssl_cert_fritzbox . '.pem');
162 162
 		curl_setopt($ch, CURLOPT_CAPATH, '/etc/ssl/certs');
163 163
 
164 164
 		// support for pre FRITZ!OS 5.50 remote config
165
-		if (!$this->config->getItem('use_lua_login_method')){
165
+		if (!$this->config->getItem('use_lua_login_method')) {
166 166
 		curl_setopt($ch, CURLOPT_USERPWD, $this->config->getItem('remote_config_user') . ':' . $this->config->getItem('remote_config_password'));
167 167
 		}
168 168
     }
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
193 193
     
194 194
     // if filefileds not specified ('@/path/to/file.xml;type=text/xml' works fine)
195
-    if(empty( $filefileds )) {
195
+    if (empty($filefileds)) {
196 196
 		curl_setopt($ch, CURLOPT_POSTFIELDS, $formfields); // http_build_query
197 197
 	} 
198 198
 	// post calculated raw data
199 199
 	else {
200 200
 		$header = $this->_create_custom_file_post_header($formfields, $filefileds);
201
-		curl_setopt($ch, CURLOPT_HTTPHEADER , array(
201
+		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
202 202
 			'Content-Type: multipart/form-data; boundary=' . $header['delimiter'], 'Content-Length: ' . strlen($header['data']) )
203 203
 			);
204 204
 			
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
     $output = curl_exec($ch);
209 209
 
210 210
 	// curl error
211
-	if(curl_errno($ch)) {
212
-		$this->error(curl_error($ch)." (".curl_errno($ch).")");
211
+	if (curl_errno($ch)) {
212
+		$this->error(curl_error($ch) . " (" . curl_errno($ch) . ")");
213 213
 	}
214 214
 
215 215
     // finger out an error message, if given
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     }    
290 290
   
291 291
     $ch = curl_init();
292
-    if ( strpos($params['getpage'], '.lua') > 0 )
292
+    if (strpos($params['getpage'], '.lua') > 0)
293 293
     {
294 294
       $getpage = $params['getpage'] . '?';
295 295
       unset($params['getpage']);
@@ -301,13 +301,13 @@  discard block
 block discarded – undo
301 301
     curl_setopt($ch, CURLOPT_URL, $this->config->getItem('fritzbox_url') . $getpage . http_build_query($params));
302 302
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
303 303
     curl_setopt($ch, CURLOPT_HTTPGET, 1);
304
-    if ( $this->config->getItem('enable_remote_config') )
304
+    if ($this->config->getItem('enable_remote_config'))
305 305
     {
306 306
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
307 307
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
308 308
 
309 309
       // support for pre FRITZ!OS 5.50 remote config
310
-      if ( !$this->config->getItem('use_lua_login_method') )
310
+      if (!$this->config->getItem('use_lua_login_method'))
311 311
       {
312 312
         curl_setopt($ch, CURLOPT_USERPWD, $this->config->getItem('remote_config_user') . ':' . $this->config->getItem('remote_config_password'));
313 313
       }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
   protected function initSID()
329 329
   {
330 330
     // determine, wich login type we have to use
331
-    if ( $this->config->getItem('use_lua_login_method') == true )
331
+    if ($this->config->getItem('use_lua_login_method') == true)
332 332
     {
333 333
       $loginpage = '/login_sid.lua';
334 334
     }
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
     // read the current status
341 341
     $session_status_simplexml = simplexml_load_string($this->doGetRequest(array('getpage' => $loginpage)));
342 342
     
343
-    if ( !is_object($session_status_simplexml) || get_class($session_status_simplexml) != 'SimpleXMLElement' )
343
+    if (!is_object($session_status_simplexml) || get_class($session_status_simplexml) != 'SimpleXMLElement')
344 344
     {
345 345
       $this->error('Response of initialization call ' . $loginpage . ' in ' . __FUNCTION__ . ' was not xml-formatted.');
346 346
     }
347 347
     
348 348
     // perhaps we already have a SID (i.e. when no password is set)
349
-    if ( $session_status_simplexml->SID != '0000000000000000' )
349
+    if ($session_status_simplexml->SID != '0000000000000000')
350 350
     {
351 351
       return $session_status_simplexml->SID;
352 352
     }
@@ -360,16 +360,16 @@  discard block
 block discarded – undo
360 360
       $formfields = array(
361 361
         'getpage' => $loginpage,
362 362
       );
363
-      if ( $this->config->getItem('use_lua_login_method') )
363
+      if ($this->config->getItem('use_lua_login_method'))
364 364
       {
365
-        if ( $this->config->getItem('enable_remote_config') )
365
+        if ($this->config->getItem('enable_remote_config'))
366 366
         {
367 367
           $formfields['username'] = $this->config->getItem('remote_config_user');
368 368
           $response = $challenge . '-' . md5(mb_convert_encoding($challenge . '-' . $this->config->getItem('remote_config_password'), "UCS-2LE", "UTF-8"));
369 369
         }
370 370
         else
371 371
         {
372
-          if ( $this->config->getItem('username') )
372
+          if ($this->config->getItem('username'))
373 373
           {
374 374
             $formfields['username'] = $this->config->getItem('username');
375 375
           }
@@ -386,12 +386,12 @@  discard block
 block discarded – undo
386 386
       
387 387
       // finger out the SID from the response
388 388
       $session_status_simplexml = simplexml_load_string($output);
389
-      if ( !is_object($session_status_simplexml) || get_class($session_status_simplexml) != 'SimpleXMLElement' )
389
+      if (!is_object($session_status_simplexml) || get_class($session_status_simplexml) != 'SimpleXMLElement')
390 390
       {
391 391
         $this->error('Response of login call to ' . $loginpage . ' in ' . __FUNCTION__ . ' was not xml-formatted.');
392 392
       }
393 393
       
394
-      if ( $session_status_simplexml->SID != '0000000000000000' )
394
+      if ($session_status_simplexml->SID != '0000000000000000')
395 395
       {
396 396
         return (string)$session_status_simplexml->SID;
397 397
       }
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     */
410 410
   protected function logout()
411 411
   {
412
-    if ( $this->config->getItem('use_lua_login_method') == true )
412
+    if ($this->config->getItem('use_lua_login_method') == true)
413 413
     {
414 414
       $this->doGetRequest(array('getpage' => '/home/home.lua', 'logout' => '1'));
415 415
     }
@@ -452,22 +452,22 @@  discard block
 block discarded – undo
452 452
     */
453 453
   public function logMessage($message)
454 454
   {
455
-    if ( $this->config->getItem('newline') == false )
455
+    if ($this->config->getItem('newline') == false)
456 456
     {
457 457
       $this->config->setItem('newline', (PHP_OS == 'WINNT') ? "\r\n" : "\n");
458 458
     }
459 459
   
460
-    if ( $this->config->getItem('logging') == 'console' )
460
+    if ($this->config->getItem('logging') == 'console')
461 461
     {
462 462
       echo $message;
463 463
     }
464
-    else if ( $this->config->getItem('logging') == 'silent' || $this->config->getItem('logging') == false )
464
+    else if ($this->config->getItem('logging') == 'silent' || $this->config->getItem('logging') == false)
465 465
     {
466 466
       // do nothing
467 467
     }
468 468
     else
469 469
     {
470
-      if ( is_writable($this->config->getItem('logging')) || is_writable(dirname($this->config->getItem('logging'))) )
470
+      if (is_writable($this->config->getItem('logging')) || is_writable(dirname($this->config->getItem('logging'))))
471 471
       {
472 472
         file_put_contents($this->config->getItem('logging'), $message . $this->config->getItem('newline'), FILE_APPEND);
473 473
       }
@@ -517,11 +517,11 @@  discard block
 block discarded – undo
517 517
    */
518 518
   public function getItem($item = 'all')
519 519
   {
520
-    if ( $item == 'all' )
520
+    if ($item == 'all')
521 521
     {
522 522
       return $this->config;
523 523
     }
524
-    elseif ( isset($this->config[$item]) )
524
+    elseif (isset($this->config[$item]))
525 525
     {
526 526
       return $this->config[$item];
527 527
     }
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_user.conf.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if ( !isset($this->config) )
2
+if (!isset($this->config))
3 3
 {
4 4
   die(__FILE__ . ' must not be called directly');
5 5
 }
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_delete_foncallslist.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 }
39 39
 
40 40
 // log the result
41
-if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' )
41
+if (isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api')
42 42
 {
43 43
   $fritz->logMessage($message);
44 44
 }
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_ring_phone.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 }
22 22
 
23 23
 // log the result
24
-if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' )
24
+if (isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api')
25 25
 {
26 26
   $fritz->logMessage($message);
27 27
 }
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_diversity0on.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 }
26 26
 
27 27
 // log the result
28
-if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' )
28
+if (isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api')
29 29
 {
30 30
   $fritz->logMessage($message);
31 31
 }
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_tam_swap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
 }
45 45
 
46 46
 // log the result
47
-if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' )
47
+if (isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api')
48 48
 {
49 49
   $fritz->logMessage($message);
50 50
 }
Please login to merge, or discard this patch.
lib/fritzbox_api_php/fritzbox_guestwlan_on_off.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
   $message = date('Y-m-d H:i') . ' ';
23 23
 
24 24
   // handle the CLI arguments or give a help message
25
-  if (isset($argv[1]) && ($argv[1] == 0 || $argv[1] == 1) )
25
+  if (isset($argv[1]) && ($argv[1] == 0 || $argv[1] == 1))
26 26
   {
27 27
     $mode = (bool)$argv[1];
28 28
   }
29 29
   else
30 30
   {
31
-    if ( $fritz->config->getItem('logging') == 'console' )
31
+    if ($fritz->config->getItem('logging') == 'console')
32 32
     {
33 33
       echo '
34 34
   Enables or disables the WLAN guest access of a Fritz!Box
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
   
64 64
   // read down_time_activ setting
65 65
   preg_match('@name="down_time_activ"[^>]+(checked)[^>]*@', $output, $matches);
66
-  if ( isset($matches[1]) )
66
+  if (isset($matches[1]))
67 67
   {
68 68
     $formfields['down_time_activ'] = 'on';
69 69
   }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
   $formfields['down_time_value'] = isset($matches[1]) ? $matches[1] : '15';
73 73
   // read disconnect_guest_access setting
74 74
   preg_match('@name="disconnect_guest_access"[^>]+(checked)[^>]*@', $output, $matches);
75
-  if ( isset($matches[1]) )
75
+  if (isset($matches[1]))
76 76
   {
77 77
     $formfields['disconnect_guest_access'] = 'on';
78 78
   }
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
   $formfields['wpa_modus'] = isset($matches[1]) ? $matches[1] : 'x';
91 91
   
92 92
   // set new given setting
93
-  if ( $mode == true )
93
+  if ($mode == true)
94 94
   {
95 95
     $formfields['activate_guest_access'] = 'on';
96
-    if ( $wpa_key !== false )
96
+    if ($wpa_key !== false)
97 97
     {
98 98
       $formfields['wpa_key'] = $wpa_key;
99 99
     }
@@ -104,23 +104,23 @@  discard block
 block discarded – undo
104 104
   $output = $fritz->doPostForm($formfields);
105 105
 
106 106
   preg_match('@name="activate_guest_access"[^>]+(checked)[^>]*@', $output, $matches);
107
-  if ( isset($matches[1]) && $mode == true )
107
+  if (isset($matches[1]) && $mode == true)
108 108
   {
109 109
 		preg_match('@name="wpa_key"[^>]+value="([^"]*)"[^>]*@', $output, $matches);
110
-		if ( isset($matches[1]) )
110
+		if (isset($matches[1]))
111 111
 		{
112 112
 			$message .= 'WLAN guest access is now active. WPA-Key is "' . $matches[1] . '"';
113 113
 		}
114 114
   }
115
-  else if ( !isset($matches[1]) && $mode == false )
115
+  else if (!isset($matches[1]) && $mode == false)
116 116
   {
117 117
     $message .= 'WLAN guest access is now inactive.';
118 118
   }
119
-  else if ( isset($matches[1]) && $mode == false )
119
+  else if (isset($matches[1]) && $mode == false)
120 120
   {
121 121
     $message .= 'ERROR: WLAN guest access status change failed, should be inactive, but is still active.';
122 122
   }
123
-  else if ( !isset($matches[1]) && $mode == true )
123
+  else if (!isset($matches[1]) && $mode == true)
124 124
   {
125 125
     $message .= 'ERROR: WLAN guest access status change failed, should be active, but is still inactive.';
126 126
   }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 }
132 132
 
133 133
 // log the result
134
-if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' )
134
+if (isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api')
135 135
 {
136 136
   $fritz->logMessage($message);
137 137
 }
Please login to merge, or discard this patch.