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
Push — master ( c2bf29...11c7a3 )
by Jens
05:50 queued 03:00
created
lib/fritzbox_api_php/fritzbox_api.class.php 1 patch
Spacing   +46 added lines, -46 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
-	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'));
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'));
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']);
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     else
138 138
     {
139 139
       // add the sid, if it is already set
140
-      if ($this->sid != '0000000000000000')
140
+      if($this->sid != '0000000000000000')
141 141
       {
142 142
         $formfields['sid'] = $this->sid;
143 143
       }   
@@ -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 {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		curl_setopt($ch, CURLOPT_CAPATH, '/etc/ssl/certs');
162 162
 
163 163
 		// support for pre FRITZ!OS 5.50 remote config
164
-		if (!$this->config->getItem('use_lua_login_method')){
164
+		if(!$this->config->getItem('use_lua_login_method')) {
165 165
 		curl_setopt($ch, CURLOPT_USERPWD, $this->config->getItem('remote_config_user') . ':' . $this->config->getItem('remote_config_password'));
166 166
 		}
167 167
     }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     $ch = curl_init();
177 177
    
178 178
     // add the sid, if it is already set
179
-    if ($this->sid != '0000000000000000')
179
+    if($this->sid != '0000000000000000')
180 180
     {
181 181
 		// 'sid' MUST be the first POST variable!!! (otherwise it will not work!!)
182 182
 		// therfore we use array_merge to ensuere the foreach outputs 'sid' fist
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
192 192
     
193 193
     // if filefileds not specified ('@/path/to/file.xml;type=text/xml' works fine)
194
-    if(empty( $filefileds )) {
194
+    if(empty($filefileds)) {
195 195
 		curl_setopt($ch, CURLOPT_POSTFIELDS, $formfields); // http_build_query
196 196
 	} 
197 197
 	// post calculated raw data
198 198
 	else {
199 199
 		$header = $this->_create_custom_file_post_header($formfields, $filefileds);
200
-		curl_setopt($ch, CURLOPT_HTTPHEADER , array(
200
+		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
201 201
 			'Content-Type: multipart/form-data; boundary=' . $header['delimiter'], 'Content-Length: ' . strlen($header['data']) )
202 202
 			);
203 203
 			
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
 
209 209
 	// curl error
210 210
 	if(curl_errno($ch)) {
211
-		$this->error(curl_error($ch)." (".curl_errno($ch).")");
211
+		$this->error(curl_error($ch) . " (" . curl_errno($ch) . ")");
212 212
 	}
213 213
 
214 214
     // finger out an error message, if given
215 215
     preg_match('@<p class="ErrorMsg">(.*?)</p>@is', $output, $matches);
216
-    if (isset($matches[1]))
216
+    if(isset($matches[1]))
217 217
     {
218 218
 		$this->error(str_replace('&nbsp;', ' ', $matches[1]));
219 219
     }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		$data = '';
245 245
 
246 246
 		// populate normal fields first (simpler)
247
-		foreach ($postFields as $name => $content) {
247
+		foreach($postFields as $name => $content) {
248 248
 		   $data .= "--" . $delimiter . "\r\n";
249 249
 			$data .= 'Content-Disposition: form-data; name="' . urlencode($name) . '"';
250 250
 			$data .= "\r\n\r\n";
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$data .= "\r\n";
253 253
 		}
254 254
 		// populate file fields
255
-		foreach ($fileFields as $name => $file) {
255
+		foreach($fileFields as $name => $file) {
256 256
 			$data .= "--" . $delimiter . "\r\n";
257 257
 			// "filename" attribute is not essential; server-side scripts may use it
258 258
 			$data .= 'Content-Disposition: form-data; name="' . urlencode($name) . '";' .
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
   public function doGetRequest($params = array())
283 283
   {
284 284
     // add the sid, if it is already set
285
-    if ($this->sid != '0000000000000000')
285
+    if($this->sid != '0000000000000000')
286 286
     {
287 287
       $params['sid'] = $this->sid;
288 288
     }    
289 289
   
290 290
     $ch = curl_init();
291
-    if ( strpos($params['getpage'], '.lua') > 0 )
291
+    if(strpos($params['getpage'], '.lua') > 0)
292 292
     {
293 293
       $getpage = $params['getpage'] . '?';
294 294
       unset($params['getpage']);
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
     curl_setopt($ch, CURLOPT_URL, $this->config->getItem('fritzbox_url') . $getpage . http_build_query($params));
301 301
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
302 302
     curl_setopt($ch, CURLOPT_HTTPGET, 1);
303
-    if ( $this->config->getItem('enable_remote_config') )
303
+    if($this->config->getItem('enable_remote_config'))
304 304
     {
305 305
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
306 306
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
307 307
 
308 308
       // support for pre FRITZ!OS 5.50 remote config
309
-      if ( !$this->config->getItem('use_lua_login_method') )
309
+      if(!$this->config->getItem('use_lua_login_method'))
310 310
       {
311 311
         curl_setopt($ch, CURLOPT_USERPWD, $this->config->getItem('remote_config_user') . ':' . $this->config->getItem('remote_config_password'));
312 312
       }
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
   protected function initSID()
328 328
   {
329 329
     // determine, wich login type we have to use
330
-    if ( $this->config->getItem('use_lua_login_method') == true )
330
+    if($this->config->getItem('use_lua_login_method') == true)
331 331
     {
332 332
       $loginpage = '/login_sid.lua';
333 333
     }
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
     // read the current status
340 340
     $session_status_simplexml = simplexml_load_string($this->doGetRequest(array('getpage' => $loginpage)));
341 341
     
342
-    if ( !is_object($session_status_simplexml) || get_class($session_status_simplexml) != 'SimpleXMLElement' )
342
+    if(!is_object($session_status_simplexml) || get_class($session_status_simplexml) != 'SimpleXMLElement')
343 343
     {
344 344
       $this->error('Response of initialization call ' . $loginpage . ' in ' . __FUNCTION__ . ' was not xml-formatted.');
345 345
     }
346 346
     
347 347
     // perhaps we already have a SID (i.e. when no password is set)
348
-    if ( $session_status_simplexml->SID != '0000000000000000' )
348
+    if($session_status_simplexml->SID != '0000000000000000')
349 349
     {
350 350
       return $session_status_simplexml->SID;
351 351
     }
@@ -359,16 +359,16 @@  discard block
 block discarded – undo
359 359
       $formfields = array(
360 360
         'getpage' => $loginpage,
361 361
       );
362
-      if ( $this->config->getItem('use_lua_login_method') )
362
+      if($this->config->getItem('use_lua_login_method'))
363 363
       {
364
-        if ( $this->config->getItem('enable_remote_config') )
364
+        if($this->config->getItem('enable_remote_config'))
365 365
         {
366 366
           $formfields['username'] = $this->config->getItem('remote_config_user');
367 367
           $response = $challenge . '-' . md5(mb_convert_encoding($challenge . '-' . $this->config->getItem('remote_config_password'), "UCS-2LE", "UTF-8"));
368 368
         }
369 369
         else
370 370
         {
371
-          if ( $this->config->getItem('username') )
371
+          if($this->config->getItem('username'))
372 372
           {
373 373
             $formfields['username'] = $this->config->getItem('username');
374 374
           }
@@ -385,12 +385,12 @@  discard block
 block discarded – undo
385 385
       
386 386
       // finger out the SID from the response
387 387
       $session_status_simplexml = simplexml_load_string($output);
388
-      if ( !is_object($session_status_simplexml) || get_class($session_status_simplexml) != 'SimpleXMLElement' )
388
+      if(!is_object($session_status_simplexml) || get_class($session_status_simplexml) != 'SimpleXMLElement')
389 389
       {
390 390
         $this->error('Response of login call to ' . $loginpage . ' in ' . __FUNCTION__ . ' was not xml-formatted.');
391 391
       }
392 392
       
393
-      if ( $session_status_simplexml->SID != '0000000000000000' )
393
+      if($session_status_simplexml->SID != '0000000000000000')
394 394
       {
395 395
         return (string)$session_status_simplexml->SID;
396 396
       }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     */
409 409
   protected function logout()
410 410
   {
411
-    if ( $this->config->getItem('use_lua_login_method') == true )
411
+    if($this->config->getItem('use_lua_login_method') == true)
412 412
     {
413 413
       $this->doGetRequest(array('getpage' => '/home/home.lua', 'logout' => '1'));
414 414
     }
@@ -451,22 +451,22 @@  discard block
 block discarded – undo
451 451
     */
452 452
   public function logMessage($message)
453 453
   {
454
-    if ( $this->config->getItem('newline') == false )
454
+    if($this->config->getItem('newline') == false)
455 455
     {
456 456
       $this->config->setItem('newline', (PHP_OS == 'WINNT') ? "\r\n" : "\n");
457 457
     }
458 458
   
459
-    if ( $this->config->getItem('logging') == 'console' )
459
+    if($this->config->getItem('logging') == 'console')
460 460
     {
461 461
       echo $message;
462 462
     }
463
-    else if ( $this->config->getItem('logging') == 'silent' || $this->config->getItem('logging') == false )
463
+    else if($this->config->getItem('logging') == 'silent' || $this->config->getItem('logging') == false)
464 464
     {
465 465
       // do nothing
466 466
     }
467 467
     else
468 468
     {
469
-      if ( is_writable($this->config->getItem('logging')) || is_writable(dirname($this->config->getItem('logging'))) )
469
+      if(is_writable($this->config->getItem('logging')) || is_writable(dirname($this->config->getItem('logging'))))
470 470
       {
471 471
         file_put_contents($this->config->getItem('logging'), $message . $this->config->getItem('newline'), FILE_APPEND);
472 472
       }
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
    */
517 517
   public function getItem($item = 'all')
518 518
   {
519
-    if ( $item == 'all' )
519
+    if($item == 'all')
520 520
     {
521 521
       return $this->config;
522 522
     }
523
-    elseif ( isset($this->config[$item]) )
523
+    elseif(isset($this->config[$item]))
524 524
     {
525 525
       return $this->config[$item];
526 526
     }
Please login to merge, or discard this patch.