@@ -23,13 +23,13 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -63,39 +63,39 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -1,5 +1,5 @@ |
||
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 | } |
@@ -44,7 +44,7 @@ |
||
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 | } |
@@ -22,13 +22,13 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | $message = date('Y-m-d H:i') . ' '; |
26 | 26 | |
27 | 27 | // handle the CLI arguments or give a help message |
28 | - if (isset($argv[1]) && ($argv[1] == 0 || $argv[1] == 1) ) |
|
28 | + if (isset($argv[1]) && ($argv[1] == 0 || $argv[1] == 1)) |
|
29 | 29 | { |
30 | 30 | $mode = (int)$argv[1]; |
31 | 31 | } |
32 | 32 | else |
33 | 33 | { |
34 | - if ( $fritz->config->getItem('logging') == 'console' ) |
|
34 | + if ($fritz->config->getItem('logging') == 'console') |
|
35 | 35 | { |
36 | 36 | echo ' |
37 | 37 | Enables or disables an answering machine (TAM) of a Fritz!Box |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | // log the result |
100 | -if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' ) |
|
100 | +if (isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api') |
|
101 | 101 | { |
102 | 102 | $fritz->logMessage($message); |
103 | 103 | } |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | // init the output message |
24 | 24 | $message = date('Y-m-d H:i') . ' '; |
25 | 25 | |
26 | - if ( !$fritz->config->getItem('foncallslist_path') ) |
|
26 | + if (!$fritz->config->getItem('foncallslist_path')) |
|
27 | 27 | { |
28 | 28 | throw new Exception('Mandatory config Item foncallslist_path not set.'); |
29 | 29 | } |
30 | - if ( ( file_exists($fritz->config->getItem('foncallslist_path')) && !is_writable($fritz->config->getItem('foncallslist_path')) ) || ( !file_exists($fritz->config->getItem('foncallslist_path')) && !is_writable(dirname($fritz->config->getItem('foncallslist_path'))) ) ) |
|
30 | + if ((file_exists($fritz->config->getItem('foncallslist_path')) && !is_writable($fritz->config->getItem('foncallslist_path'))) || (!file_exists($fritz->config->getItem('foncallslist_path')) && !is_writable(dirname($fritz->config->getItem('foncallslist_path'))))) |
|
31 | 31 | { |
32 | 32 | throw new Exception('Config item foncallslist_path (' . $fritz->config->getItem('foncallslist_path') . ') is not writeable.'); |
33 | 33 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // log the result |
64 | -if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' ) |
|
64 | +if (isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api') |
|
65 | 65 | { |
66 | 66 | $fritz->logMessage($message); |
67 | 67 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @var string Current object mode - error, single or multiple (for a single vCard within a file and multiple combined vCards) |
20 | 20 | */ |
21 | - private $Mode; //single, multiple, error |
|
21 | + private $Mode; //single, multiple, error |
|
22 | 22 | |
23 | 23 | private $Path = ''; |
24 | 24 | private $RawData = ''; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | { |
80 | 80 | if (!is_readable($Path)) |
81 | 81 | { |
82 | - throw new Exception('vCard: Path not accessible ('.$Path.')'); |
|
82 | + throw new Exception('vCard: Path not accessible (' . $Path . ')'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | $this -> Path = $Path; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | { |
135 | 135 | // Prepending "BEGIN:VCARD" to the raw string because we exploded on that one. |
136 | 136 | // If there won't be the BEGIN marker in the new object, it will fail. |
137 | - $SinglevCardRawData = 'BEGIN:VCARD'."\n".$SinglevCardRawData; |
|
137 | + $SinglevCardRawData = 'BEGIN:VCARD' . "\n" . $SinglevCardRawData; |
|
138 | 138 | |
139 | 139 | $ClassName = get_class($this); |
140 | 140 | $this -> Data[] = new $ClassName(false, $SinglevCardRawData); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | } |
378 | 378 | else |
379 | 379 | { |
380 | - throw new Exception('vCard: Cannot save file ('.$Key.'), target path not writable ('.$TargetPath.')'); |
|
380 | + throw new Exception('vCard: Cannot save file (' . $Key . '), target path not writable (' . $TargetPath . ')'); |
|
381 | 381 | } |
382 | 382 | return false; |
383 | 383 | } |
@@ -458,8 +458,8 @@ discard block |
||
458 | 458 | */ |
459 | 459 | public function __toString() |
460 | 460 | { |
461 | - $Text = 'BEGIN:VCARD'.self::endl; |
|
462 | - $Text .= 'VERSION:3.0'.self::endl; |
|
461 | + $Text = 'BEGIN:VCARD' . self::endl; |
|
462 | + $Text .= 'VERSION:3.0' . self::endl; |
|
463 | 463 | |
464 | 464 | foreach ($this -> Data as $Key => $Values) |
465 | 465 | { |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $Text .= $KeyUC; |
477 | 477 | if (is_array($Value) && isset($Value['type'])) |
478 | 478 | { |
479 | - $Text .= ';TYPE='.self::PrepareTypeStrForOutput($Value['type']); |
|
479 | + $Text .= ';TYPE=' . self::PrepareTypeStrForOutput($Value['type']); |
|
480 | 480 | } |
481 | 481 | $Text .= ':'; |
482 | 482 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | } |
503 | 503 | } |
504 | 504 | |
505 | - $Text .= 'END:VCARD'.self::endl; |
|
505 | + $Text .= 'END:VCARD' . self::endl; |
|
506 | 506 | return $Text; |
507 | 507 | } |
508 | 508 | |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | } |
604 | 604 | elseif (count($Parameter) > 2) |
605 | 605 | { |
606 | - if(count(explode(',', $RawParams[$Index], -1)) > 0) |
|
606 | + if (count(explode(',', $RawParams[$Index], -1)) > 0) |
|
607 | 607 | { |
608 | 608 | $TempTypeParams = self::ParseParameters($Key, explode(',', $RawParams[$Index])); |
609 | 609 | if ($TempTypeParams['type']) |
@@ -16,5 +16,5 @@ |
||
16 | 16 | |
17 | 17 | //$vCard = new vCard('Example3.0.vcf'); |
18 | 18 | |
19 | - echo '<pre>'.$vCard.'</pre>'; |
|
19 | + echo '<pre>' . $vCard . '</pre>'; |
|
20 | 20 | ?> |
21 | 21 | \ No newline at end of file |