@@ -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 | } |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | if (isset($argv[1]) && ($argv[1] == 0 || $argv[1] == 1) ) |
| 26 | 26 | { |
| 27 | 27 | $mode = (bool)$argv[1]; |
| 28 | - } |
|
| 29 | - else |
|
| 28 | + } else |
|
| 30 | 29 | { |
| 31 | 30 | if ( $fritz->config->getItem('logging') == 'console' ) |
| 32 | 31 | { |
@@ -45,8 +44,7 @@ discard block |
||
| 45 | 44 | The optional argument PASSWORD sets a new guest access password (min 8 chars) |
| 46 | 45 | Defaults to false, so the current password is kept. |
| 47 | 46 | '; |
| 48 | - } |
|
| 49 | - else |
|
| 47 | + } else |
|
| 50 | 48 | { |
| 51 | 49 | $fritz->logMessage($message . 'ERROR: Script was called without or with an invalid argument'); |
| 52 | 50 | } |
@@ -111,21 +109,17 @@ discard block |
||
| 111 | 109 | { |
| 112 | 110 | $message .= 'WLAN guest access is now active. WPA-Key is "' . $matches[1] . '"'; |
| 113 | 111 | } |
| 114 | - } |
|
| 115 | - else if ( !isset($matches[1]) && $mode == false ) |
|
| 112 | + } else if ( !isset($matches[1]) && $mode == false ) |
|
| 116 | 113 | { |
| 117 | 114 | $message .= 'WLAN guest access is now inactive.'; |
| 118 | - } |
|
| 119 | - else if ( isset($matches[1]) && $mode == false ) |
|
| 115 | + } else if ( isset($matches[1]) && $mode == false ) |
|
| 120 | 116 | { |
| 121 | 117 | $message .= 'ERROR: WLAN guest access status change failed, should be inactive, but is still active.'; |
| 122 | - } |
|
| 123 | - else if ( !isset($matches[1]) && $mode == true ) |
|
| 118 | + } else if ( !isset($matches[1]) && $mode == true ) |
|
| 124 | 119 | { |
| 125 | 120 | $message .= 'ERROR: WLAN guest access status change failed, should be active, but is still inactive.'; |
| 126 | 121 | } |
| 127 | -} |
|
| 128 | -catch (Exception $e) |
|
| 122 | +} catch (Exception $e) |
|
| 129 | 123 | { |
| 130 | 124 | $message .= $e->getMessage(); |
| 131 | 125 | } |
@@ -134,8 +128,7 @@ discard block |
||
| 134 | 128 | if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' ) |
| 135 | 129 | { |
| 136 | 130 | $fritz->logMessage($message); |
| 137 | -} |
|
| 138 | -else |
|
| 131 | +} else |
|
| 139 | 132 | { |
| 140 | 133 | echo($message); |
| 141 | 134 | } |
@@ -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 | } |
@@ -98,8 +98,7 @@ discard block |
||
| 98 | 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 | - } |
|
| 102 | - else { |
|
| 101 | + } else { |
|
| 103 | 102 | $this->config->setItem('old_remote_config_user', null); |
| 104 | 103 | $this->config->setItem('old_remote_config_password', null); |
| 105 | 104 | } |
@@ -133,8 +132,7 @@ discard block |
||
| 133 | 132 | { |
| 134 | 133 | curl_setopt($ch, CURLOPT_URL, $this->config->getItem('fritzbox_url') . $formfields['getpage'] . '?sid=' . $this->sid); |
| 135 | 134 | unset($formfields['getpage']); |
| 136 | - } |
|
| 137 | - else |
|
| 135 | + } else |
|
| 138 | 136 | { |
| 139 | 137 | // add the sid, if it is already set |
| 140 | 138 | if ($this->sid != '0000000000000000') |
@@ -293,8 +291,7 @@ discard block |
||
| 293 | 291 | { |
| 294 | 292 | $getpage = $params['getpage'] . '?'; |
| 295 | 293 | unset($params['getpage']); |
| 296 | - } |
|
| 297 | - else |
|
| 294 | + } else |
|
| 298 | 295 | { |
| 299 | 296 | $getpage = '/cgi-bin/webcm?'; |
| 300 | 297 | } |
@@ -331,8 +328,7 @@ discard block |
||
| 331 | 328 | if ( $this->config->getItem('use_lua_login_method') == true ) |
| 332 | 329 | { |
| 333 | 330 | $loginpage = '/login_sid.lua'; |
| 334 | - } |
|
| 335 | - else |
|
| 331 | + } else |
|
| 336 | 332 | { |
| 337 | 333 | $loginpage = '../html/login_sid.xml'; |
| 338 | 334 | } |
@@ -366,8 +362,7 @@ discard block |
||
| 366 | 362 | { |
| 367 | 363 | $formfields['username'] = $this->config->getItem('remote_config_user'); |
| 368 | 364 | $response = $challenge . '-' . md5(mb_convert_encoding($challenge . '-' . $this->config->getItem('remote_config_password'), "UCS-2LE", "UTF-8")); |
| 369 | - } |
|
| 370 | - else |
|
| 365 | + } else |
|
| 371 | 366 | { |
| 372 | 367 | if ( $this->config->getItem('username') ) |
| 373 | 368 | { |
@@ -376,8 +371,7 @@ discard block |
||
| 376 | 371 | $response = $challenge . '-' . md5(mb_convert_encoding($challenge . '-' . $this->config->getItem('password'), "UCS-2LE", "UTF-8")); |
| 377 | 372 | } |
| 378 | 373 | $formfields['response'] = $response; |
| 379 | - } |
|
| 380 | - else |
|
| 374 | + } else |
|
| 381 | 375 | { |
| 382 | 376 | $response = $challenge . '-' . md5(mb_convert_encoding($challenge . '-' . $this->config->getItem('password'), "UCS-2LE", "UTF-8")); |
| 383 | 377 | $formfields['login:command/response'] = $response; |
@@ -394,8 +388,7 @@ discard block |
||
| 394 | 388 | if ( $session_status_simplexml->SID != '0000000000000000' ) |
| 395 | 389 | { |
| 396 | 390 | return (string)$session_status_simplexml->SID; |
| 397 | - } |
|
| 398 | - else |
|
| 391 | + } else |
|
| 399 | 392 | { |
| 400 | 393 | $this->error('ERROR: Login failed with an unknown response.'); |
| 401 | 394 | } |
@@ -412,8 +405,7 @@ discard block |
||
| 412 | 405 | if ( $this->config->getItem('use_lua_login_method') == true ) |
| 413 | 406 | { |
| 414 | 407 | $this->doGetRequest(array('getpage' => '/home/home.lua', 'logout' => '1')); |
| 415 | - } |
|
| 416 | - else |
|
| 408 | + } else |
|
| 417 | 409 | { |
| 418 | 410 | $formfields = array( |
| 419 | 411 | 'getpage' => '../html/de/menus/menu2.html', |
@@ -460,18 +452,15 @@ discard block |
||
| 460 | 452 | if ( $this->config->getItem('logging') == 'console' ) |
| 461 | 453 | { |
| 462 | 454 | echo $message; |
| 463 | - } |
|
| 464 | - else if ( $this->config->getItem('logging') == 'silent' || $this->config->getItem('logging') == false ) |
|
| 455 | + } else if ( $this->config->getItem('logging') == 'silent' || $this->config->getItem('logging') == false ) |
|
| 465 | 456 | { |
| 466 | 457 | // do nothing |
| 467 | - } |
|
| 468 | - else |
|
| 458 | + } else |
|
| 469 | 459 | { |
| 470 | 460 | if ( is_writable($this->config->getItem('logging')) || is_writable(dirname($this->config->getItem('logging'))) ) |
| 471 | 461 | { |
| 472 | 462 | file_put_contents($this->config->getItem('logging'), $message . $this->config->getItem('newline'), FILE_APPEND); |
| 473 | - } |
|
| 474 | - else |
|
| 463 | + } else |
|
| 475 | 464 | { |
| 476 | 465 | echo('Error: Cannot log to non-writeable file or dir: ' . $this->config->getItem('logging')); |
| 477 | 466 | } |
@@ -520,8 +509,7 @@ discard block |
||
| 520 | 509 | if ( $item == 'all' ) |
| 521 | 510 | { |
| 522 | 511 | return $this->config; |
| 523 | - } |
|
| 524 | - elseif ( isset($this->config[$item]) ) |
|
| 512 | + } elseif ( isset($this->config[$item]) ) |
|
| 525 | 513 | { |
| 526 | 514 | return $this->config[$item]; |
| 527 | 515 | } |
@@ -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 | } |
@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | // set a log message |
| 56 | 56 | $message .= 'Call list sucessfully downloaded'; |
| 57 | -} |
|
| 58 | -catch (Exception $e) |
|
| 57 | +} catch (Exception $e) |
|
| 59 | 58 | { |
| 60 | 59 | $message .= $e->getMessage(); |
| 61 | 60 | } |
@@ -64,8 +63,7 @@ discard block |
||
| 64 | 63 | if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' ) |
| 65 | 64 | { |
| 66 | 65 | $fritz->logMessage($message); |
| 67 | -} |
|
| 68 | -else |
|
| 66 | +} else |
|
| 69 | 67 | { |
| 70 | 68 | echo($message); |
| 71 | 69 | } |
@@ -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,8 +25,7 @@ discard block |
||
| 25 | 25 | if (isset($argv[1]) && ($argv[1] == 0 || $argv[1] == 1) ) |
| 26 | 26 | { |
| 27 | 27 | $mode = (bool)$argv[1]; |
| 28 | - } |
|
| 29 | - else |
|
| 28 | + } else |
|
| 30 | 29 | { |
| 31 | 30 | if ( $fritz->config->getItem('logging') == 'console' ) |
| 32 | 31 | { |
@@ -45,8 +44,7 @@ discard block |
||
| 45 | 44 | The optional argument PASSWORD sets a new guest access password (min 8 chars) |
| 46 | 45 | Defaults to false, so the current password is kept. |
| 47 | 46 | '; |
| 48 | - } |
|
| 49 | - else |
|
| 47 | + } else |
|
| 50 | 48 | { |
| 51 | 49 | $fritz->logMessage($message . 'ERROR: Script was called without or with an invalid argument'); |
| 52 | 50 | } |
@@ -111,21 +109,17 @@ discard block |
||
| 111 | 109 | { |
| 112 | 110 | $message .= 'WLAN guest access is now active. WPA-Key is "' . $matches[1] . '"'; |
| 113 | 111 | } |
| 114 | - } |
|
| 115 | - else if ( !isset($matches[1]) && $mode == false ) |
|
| 112 | + } else if ( !isset($matches[1]) && $mode == false ) |
|
| 116 | 113 | { |
| 117 | 114 | $message .= 'WLAN guest access is now inactive.'; |
| 118 | - } |
|
| 119 | - else if ( isset($matches[1]) && $mode == false ) |
|
| 115 | + } else if ( isset($matches[1]) && $mode == false ) |
|
| 120 | 116 | { |
| 121 | 117 | $message .= 'ERROR: WLAN guest access status change failed, should be inactive, but is still active.'; |
| 122 | - } |
|
| 123 | - else if ( !isset($matches[1]) && $mode == true ) |
|
| 118 | + } else if ( !isset($matches[1]) && $mode == true ) |
|
| 124 | 119 | { |
| 125 | 120 | $message .= 'ERROR: WLAN guest access status change failed, should be active, but is still inactive.'; |
| 126 | 121 | } |
| 127 | -} |
|
| 128 | -catch (Exception $e) |
|
| 122 | +} catch (Exception $e) |
|
| 129 | 123 | { |
| 130 | 124 | $message .= $e->getMessage(); |
| 131 | 125 | } |
@@ -134,8 +128,7 @@ discard block |
||
| 134 | 128 | if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' ) |
| 135 | 129 | { |
| 136 | 130 | $fritz->logMessage($message); |
| 137 | -} |
|
| 138 | -else |
|
| 131 | +} else |
|
| 139 | 132 | { |
| 140 | 133 | echo($message); |
| 141 | 134 | } |
@@ -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 | } |
@@ -28,8 +28,7 @@ discard block |
||
| 28 | 28 | if (isset($argv[1]) && ($argv[1] == 0 || $argv[1] == 1) ) |
| 29 | 29 | { |
| 30 | 30 | $mode = (int)$argv[1]; |
| 31 | - } |
|
| 32 | - else |
|
| 31 | + } else |
|
| 33 | 32 | { |
| 34 | 33 | if ( $fritz->config->getItem('logging') == 'console' ) |
| 35 | 34 | { |
@@ -51,8 +50,7 @@ discard block |
||
| 51 | 50 | Warning: A non existent TAM will not lead to an error message but adds a |
| 52 | 51 | new TAM to the Fritz!Box, which will answer all incoming calls by default! |
| 53 | 52 | '; |
| 54 | - } |
|
| 55 | - else |
|
| 53 | + } else |
|
| 56 | 54 | { |
| 57 | 55 | $fritz->logMessage($message . 'ERROR: Script was called without or with an invalid argument'); |
| 58 | 56 | } |
@@ -81,17 +79,14 @@ discard block |
||
| 81 | 79 | if (isset($matches[1]) && $matches[1] == $mode) |
| 82 | 80 | { |
| 83 | 81 | $message .= $mode == 1 ? 'TAM' . $tam . ' enabled' : 'TAM' . $tam . ' disabled'; |
| 84 | - } |
|
| 85 | - else if (isset($matches[1])) |
|
| 82 | + } else if (isset($matches[1])) |
|
| 86 | 83 | { |
| 87 | 84 | $message .= 'ERROR: TAM' . $tam . ' status change failed, should be ' . $mode . ', but is ' . $matches[1]; |
| 88 | - } |
|
| 89 | - else |
|
| 85 | + } else |
|
| 90 | 86 | { |
| 91 | 87 | $message .= 'NOTICE: TAM' . $tam . ' status change could have failed, should be ' . $mode . ' now, but I don\'t now if it actually is. Check your check section in the script.'; |
| 92 | 88 | } |
| 93 | -} |
|
| 94 | -catch (Exception $e) |
|
| 89 | +} catch (Exception $e) |
|
| 95 | 90 | { |
| 96 | 91 | $message .= $e->getMessage(); |
| 97 | 92 | } |
@@ -100,8 +95,7 @@ discard block |
||
| 100 | 95 | if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' ) |
| 101 | 96 | { |
| 102 | 97 | $fritz->logMessage($message); |
| 103 | -} |
|
| 104 | -else |
|
| 98 | +} else |
|
| 105 | 99 | { |
| 106 | 100 | echo($message); |
| 107 | 101 | } |
@@ -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 | } |
@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | // set a log message |
| 56 | 56 | $message .= 'Call list sucessfully downloaded'; |
| 57 | -} |
|
| 58 | -catch (Exception $e) |
|
| 57 | +} catch (Exception $e) |
|
| 59 | 58 | { |
| 60 | 59 | $message .= $e->getMessage(); |
| 61 | 60 | } |
@@ -64,8 +63,7 @@ discard block |
||
| 64 | 63 | if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' ) |
| 65 | 64 | { |
| 66 | 65 | $fritz->logMessage($message); |
| 67 | -} |
|
| 68 | -else |
|
| 66 | +} else |
|
| 69 | 67 | { |
| 70 | 68 | echo($message); |
| 71 | 69 | } |
@@ -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']) |
@@ -84,12 +84,10 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $this -> Path = $Path; |
| 86 | 86 | $this -> RawData = file_get_contents($this -> Path); |
| 87 | - } |
|
| 88 | - elseif ($RawData) |
|
| 87 | + } elseif ($RawData) |
|
| 89 | 88 | { |
| 90 | 89 | $this -> RawData = $RawData; |
| 91 | - } |
|
| 92 | - else |
|
| 90 | + } else |
|
| 93 | 91 | { |
| 94 | 92 | //throw new Exception('vCard: No content provided'); |
| 95 | 93 | // Not necessary anymore as possibility to create vCards is added |
@@ -139,8 +137,7 @@ discard block |
||
| 139 | 137 | $ClassName = get_class($this); |
| 140 | 138 | $this -> Data[] = new $ClassName(false, $SinglevCardRawData); |
| 141 | 139 | } |
| 142 | - } |
|
| 143 | - else |
|
| 140 | + } else |
|
| 144 | 141 | { |
| 145 | 142 | // Protect the BASE64 final = sign (detected by the line beginning with whitespace), otherwise the next replace will get rid of it |
| 146 | 143 | $this -> RawData = preg_replace('{(\n\s.+)=(\n)}', '$1-base64=-$2', $this -> RawData); |
@@ -190,8 +187,7 @@ discard block |
||
| 190 | 187 | } |
| 191 | 188 | $this -> Data[$Key][] = $Value; |
| 192 | 189 | continue; |
| 193 | - } |
|
| 194 | - else |
|
| 190 | + } else |
|
| 195 | 191 | { |
| 196 | 192 | $Value = str_replace('-wrap-', '', $Value); |
| 197 | 193 | } |
@@ -224,11 +220,12 @@ discard block |
||
| 224 | 220 | if (in_array($ParamValue, array('b', 'base64'))) |
| 225 | 221 | { |
| 226 | 222 | //$Value = base64_decode($Value); |
| 227 | - } |
|
| 228 | - elseif ($ParamValue == 'quoted-printable') // v2.1 |
|
| 223 | + } elseif ($ParamValue == 'quoted-printable') { |
|
| 224 | + // v2.1 |
|
| 229 | 225 | { |
| 230 | 226 | $Value = quoted_printable_decode($Value); |
| 231 | 227 | } |
| 228 | + } |
|
| 232 | 229 | break; |
| 233 | 230 | case 'charset': // v2.1 |
| 234 | 231 | if ($ParamValue != 'utf-8' && $ParamValue != 'utf8') |
@@ -263,8 +260,7 @@ discard block |
||
| 263 | 260 | { |
| 264 | 261 | $Value['type'] = $Type; |
| 265 | 262 | } |
| 266 | - } |
|
| 267 | - else |
|
| 263 | + } else |
|
| 268 | 264 | { |
| 269 | 265 | if (in_array($Key, self::$Spec_MultipleValueElements)) |
| 270 | 266 | { |
@@ -311,8 +307,7 @@ discard block |
||
| 311 | 307 | if ($Key == 'agent') |
| 312 | 308 | { |
| 313 | 309 | return $this -> Data[$Key]; |
| 314 | - } |
|
| 315 | - elseif (in_array($Key, self::$Spec_FileElements)) |
|
| 310 | + } elseif (in_array($Key, self::$Spec_FileElements)) |
|
| 316 | 311 | { |
| 317 | 312 | $Value = $this -> Data[$Key]; |
| 318 | 313 | foreach ($Value as $K => $V) |
@@ -331,8 +326,7 @@ discard block |
||
| 331 | 326 | return $this -> Data[$Key][0]; |
| 332 | 327 | } |
| 333 | 328 | return $this -> Data[$Key]; |
| 334 | - } |
|
| 335 | - elseif ($Key == 'Mode') |
|
| 329 | + } elseif ($Key == 'Mode') |
|
| 336 | 330 | { |
| 337 | 331 | return $this -> Mode; |
| 338 | 332 | } |
@@ -374,8 +368,7 @@ discard block |
||
| 374 | 368 | } |
| 375 | 369 | $Status = file_put_contents($TargetPath, $RawContent); |
| 376 | 370 | return (bool)$Status; |
| 377 | - } |
|
| 378 | - else |
|
| 371 | + } else |
|
| 379 | 372 | { |
| 380 | 373 | throw new Exception('vCard: Cannot save file ('.$Key.'), target path not writable ('.$TargetPath.')'); |
| 381 | 374 | } |
@@ -421,8 +414,7 @@ discard block |
||
| 421 | 414 | if (empty($this -> Data[$Key][$LastElementIndex][$Types[0]])) |
| 422 | 415 | { |
| 423 | 416 | $this -> Data[$Key][$LastElementIndex][$Types[0]] = $Value; |
| 424 | - } |
|
| 425 | - else |
|
| 417 | + } else |
|
| 426 | 418 | { |
| 427 | 419 | $LastElementIndex++; |
| 428 | 420 | } |
@@ -434,16 +426,14 @@ discard block |
||
| 434 | 426 | $Types[0] => $Value |
| 435 | 427 | ); |
| 436 | 428 | } |
| 437 | - } |
|
| 438 | - elseif (isset(self::$Spec_ElementTypes[$Key])) |
|
| 429 | + } elseif (isset(self::$Spec_ElementTypes[$Key])) |
|
| 439 | 430 | { |
| 440 | 431 | $this -> Data[$Key][] = array( |
| 441 | 432 | 'value' => $Value, |
| 442 | 433 | 'type' => $Types |
| 443 | 434 | ); |
| 444 | 435 | } |
| 445 | - } |
|
| 446 | - elseif ($Value) |
|
| 436 | + } elseif ($Value) |
|
| 447 | 437 | { |
| 448 | 438 | $this -> Data[$Key][] = $Value; |
| 449 | 439 | } |
@@ -488,12 +478,10 @@ discard block |
||
| 488 | 478 | $PartArray[] = isset($Value[$Part]) ? $Value[$Part] : ''; |
| 489 | 479 | } |
| 490 | 480 | $Text .= implode(';', $PartArray); |
| 491 | - } |
|
| 492 | - elseif (is_array($Value) && isset(self::$Spec_ElementTypes[$Key])) |
|
| 481 | + } elseif (is_array($Value) && isset(self::$Spec_ElementTypes[$Key])) |
|
| 493 | 482 | { |
| 494 | 483 | $Text .= $Value['value']; |
| 495 | - } |
|
| 496 | - else |
|
| 484 | + } else |
|
| 497 | 485 | { |
| 498 | 486 | $Text .= $Value; |
| 499 | 487 | } |
@@ -600,8 +588,7 @@ discard block |
||
| 600 | 588 | { |
| 601 | 589 | $Type[] = $Parameter[0]; |
| 602 | 590 | } |
| 603 | - } |
|
| 604 | - elseif (count($Parameter) > 2) |
|
| 591 | + } elseif (count($Parameter) > 2) |
|
| 605 | 592 | { |
| 606 | 593 | if(count(explode(',', $RawParams[$Index], -1)) > 0) |
| 607 | 594 | { |
@@ -611,8 +598,7 @@ discard block |
||
| 611 | 598 | $Type = array_merge($Type, $TempTypeParams['type']); |
| 612 | 599 | } |
| 613 | 600 | } |
| 614 | - } |
|
| 615 | - else |
|
| 601 | + } else |
|
| 616 | 602 | { |
| 617 | 603 | switch ($Parameter[0]) |
| 618 | 604 | { |
@@ -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 |