@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function OutputvCard(vCard $vCard) |
| 36 | 36 | { |
| 37 | - echo '<h2>'.$vCard -> FN[0].'</h2>'; |
|
| 37 | + echo '<h2>' . $vCard -> FN[0] . '</h2>'; |
|
| 38 | 38 | |
| 39 | - if ($vCard -> PHOTO) |
|
| 39 | + if($vCard -> PHOTO) |
|
| 40 | 40 | { |
| 41 | - foreach ($vCard -> PHOTO as $Photo) |
|
| 41 | + foreach($vCard -> PHOTO as $Photo) |
|
| 42 | 42 | { |
| 43 | - if ($Photo['encoding'] == 'b') |
|
| 43 | + if($Photo['encoding'] == 'b') |
|
| 44 | 44 | { |
| 45 | - echo '<img src="data:image/'.$Photo['type'][0].';base64,'.$Photo['value'].'" /><br />'; |
|
| 45 | + echo '<img src="data:image/' . $Photo['type'][0] . ';base64,' . $Photo['value'] . '" /><br />'; |
|
| 46 | 46 | } |
| 47 | 47 | else |
| 48 | 48 | { |
| 49 | - echo '<img src="'.$Photo['value'].'" /><br />'; |
|
| 49 | + echo '<img src="' . $Photo['value'] . '" /><br />'; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /* |
@@ -67,114 +67,113 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - foreach ($vCard -> N as $Name) |
|
| 70 | + foreach($vCard -> N as $Name) |
|
| 71 | 71 | { |
| 72 | - echo '<h3>Name: '.$Name['firstname'].' '.$Name['lastname'].'</h3>'; |
|
| 72 | + echo '<h3>Name: ' . $Name['firstname'] . ' ' . $Name['lastname'] . '</h3>'; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - foreach ($vCard -> ORG as $Organization) |
|
| 75 | + foreach($vCard -> ORG as $Organization) |
|
| 76 | 76 | { |
| 77 | - echo '<h3>Organization: '.$Organization['name']. |
|
| 77 | + echo '<h3>Organization: ' . $Organization['name'] . |
|
| 78 | 78 | ($Organization['unit1'] || $Organization['unit2'] ? |
| 79 | - ' ('.implode(', ', array($Organization['unit1'], $Organization['unit2'])).')' : |
|
| 80 | - '' |
|
| 81 | - ).'</h3>'; |
|
| 79 | + ' (' . implode(', ', array($Organization['unit1'], $Organization['unit2'])) . ')' : '' |
|
| 80 | + ) . '</h3>'; |
|
| 82 | 81 | } |
| 83 | 82 | |
| 84 | - if ($vCard -> TEL) |
|
| 83 | + if($vCard -> TEL) |
|
| 85 | 84 | { |
| 86 | 85 | echo '<p><h4>Phone</h4>'; |
| 87 | - foreach ($vCard -> TEL as $Tel) |
|
| 86 | + foreach($vCard -> TEL as $Tel) |
|
| 88 | 87 | { |
| 89 | - if (is_scalar($Tel)) |
|
| 88 | + if(is_scalar($Tel)) |
|
| 90 | 89 | { |
| 91 | - echo $Tel.'<br />'; |
|
| 90 | + echo $Tel . '<br />'; |
|
| 92 | 91 | } |
| 93 | 92 | else |
| 94 | 93 | { |
| 95 | - echo $Tel['value'].' ('.implode(', ', $Tel['type']).')<br />'; |
|
| 94 | + echo $Tel['value'] . ' (' . implode(', ', $Tel['type']) . ')<br />'; |
|
| 96 | 95 | } |
| 97 | 96 | } |
| 98 | 97 | echo '</p>'; |
| 99 | 98 | } |
| 100 | 99 | |
| 101 | - if ($vCard -> EMAIL) |
|
| 100 | + if($vCard -> EMAIL) |
|
| 102 | 101 | { |
| 103 | 102 | echo '<p><h4>Email</h4>'; |
| 104 | - foreach ($vCard -> EMAIL as $Email) |
|
| 103 | + foreach($vCard -> EMAIL as $Email) |
|
| 105 | 104 | { |
| 106 | - if (is_scalar($Email)) |
|
| 105 | + if(is_scalar($Email)) |
|
| 107 | 106 | { |
| 108 | 107 | echo $Email; |
| 109 | 108 | } |
| 110 | 109 | else |
| 111 | 110 | { |
| 112 | - echo $Email['value'].' ('.implode(', ', $Email['type']).')<br />'; |
|
| 111 | + echo $Email['value'] . ' (' . implode(', ', $Email['type']) . ')<br />'; |
|
| 113 | 112 | } |
| 114 | 113 | } |
| 115 | 114 | echo '</p>'; |
| 116 | 115 | } |
| 117 | 116 | |
| 118 | - if ($vCard -> URL) |
|
| 117 | + if($vCard -> URL) |
|
| 119 | 118 | { |
| 120 | 119 | echo '<p><h4>URL</h4>'; |
| 121 | - foreach ($vCard -> URL as $URL) |
|
| 120 | + foreach($vCard -> URL as $URL) |
|
| 122 | 121 | { |
| 123 | - if (is_scalar($URL)) |
|
| 122 | + if(is_scalar($URL)) |
|
| 124 | 123 | { |
| 125 | - echo $URL.'<br />'; |
|
| 124 | + echo $URL . '<br />'; |
|
| 126 | 125 | } |
| 127 | 126 | else |
| 128 | 127 | { |
| 129 | - echo $URL['value'].'<br />'; |
|
| 128 | + echo $URL['value'] . '<br />'; |
|
| 130 | 129 | } |
| 131 | 130 | } |
| 132 | 131 | echo '</p>'; |
| 133 | 132 | } |
| 134 | 133 | |
| 135 | - if ($vCard -> IMPP) |
|
| 134 | + if($vCard -> IMPP) |
|
| 136 | 135 | { |
| 137 | 136 | echo '<p><h4>Instant messaging</h4>'; |
| 138 | - foreach ($vCard -> IMPP as $IMPP) |
|
| 137 | + foreach($vCard -> IMPP as $IMPP) |
|
| 139 | 138 | { |
| 140 | - if (is_scalar($IMPP)) |
|
| 139 | + if(is_scalar($IMPP)) |
|
| 141 | 140 | { |
| 142 | - echo $IMPP.'<br />'; |
|
| 141 | + echo $IMPP . '<br />'; |
|
| 143 | 142 | } |
| 144 | 143 | else |
| 145 | 144 | { |
| 146 | - echo $IMPP['value'].'<br/ >'; |
|
| 145 | + echo $IMPP['value'] . '<br/ >'; |
|
| 147 | 146 | } |
| 148 | 147 | } |
| 149 | 148 | echo '</p>'; |
| 150 | 149 | } |
| 151 | 150 | |
| 152 | - if ($vCard -> ADR) |
|
| 151 | + if($vCard -> ADR) |
|
| 153 | 152 | { |
| 154 | - foreach ($vCard -> ADR as $Address) |
|
| 153 | + foreach($vCard -> ADR as $Address) |
|
| 155 | 154 | { |
| 156 | - echo '<p><h4>Address ('.implode(', ', $Address['type']).')</h4>'; |
|
| 157 | - echo 'Street address: <strong>'.($Address['streetaddress'] ? $Address['streetaddress'] : '-').'</strong><br />'. |
|
| 158 | - 'PO Box: <strong>'.($Address['pobox'] ? $Address['pobox'] : '-').'</strong><br />'. |
|
| 159 | - 'Extended address: <strong>'.($Address['extendedaddress'] ? $Address['extendedaddress'] : '-').'</strong><br />'. |
|
| 160 | - 'Locality: <strong>'.($Address['locality'] ? $Address['locality'] : '-').'</strong><br />'. |
|
| 161 | - 'Region: <strong>'.($Address['region'] ? $Address['region'] : '-').'</strong><br />'. |
|
| 162 | - 'ZIP/Post code: <strong>'.($Address['postalcode'] ? $Address['postalcode'] : '-').'</strong><br />'. |
|
| 163 | - 'Country: <strong>'.($Address['country'] ? $Address['country'] : '-').'</strong>'; |
|
| 155 | + echo '<p><h4>Address (' . implode(', ', $Address['type']) . ')</h4>'; |
|
| 156 | + echo 'Street address: <strong>' . ($Address['streetaddress'] ? $Address['streetaddress'] : '-') . '</strong><br />' . |
|
| 157 | + 'PO Box: <strong>' . ($Address['pobox'] ? $Address['pobox'] : '-') . '</strong><br />' . |
|
| 158 | + 'Extended address: <strong>' . ($Address['extendedaddress'] ? $Address['extendedaddress'] : '-') . '</strong><br />' . |
|
| 159 | + 'Locality: <strong>' . ($Address['locality'] ? $Address['locality'] : '-') . '</strong><br />' . |
|
| 160 | + 'Region: <strong>' . ($Address['region'] ? $Address['region'] : '-') . '</strong><br />' . |
|
| 161 | + 'ZIP/Post code: <strong>' . ($Address['postalcode'] ? $Address['postalcode'] : '-') . '</strong><br />' . |
|
| 162 | + 'Country: <strong>' . ($Address['country'] ? $Address['country'] : '-') . '</strong>'; |
|
| 164 | 163 | } |
| 165 | 164 | echo '</p>'; |
| 166 | 165 | } |
| 167 | 166 | |
| 168 | - if ($vCard -> AGENT) |
|
| 167 | + if($vCard -> AGENT) |
|
| 169 | 168 | { |
| 170 | 169 | echo '<h4>Agents</h4>'; |
| 171 | - foreach ($vCard -> AGENT as $Agent) |
|
| 170 | + foreach($vCard -> AGENT as $Agent) |
|
| 172 | 171 | { |
| 173 | - if (is_scalar($Agent)) |
|
| 172 | + if(is_scalar($Agent)) |
|
| 174 | 173 | { |
| 175 | - echo '<div class="Agent">'.$Agent.'</div>'; |
|
| 174 | + echo '<div class="Agent">' . $Agent . '</div>'; |
|
| 176 | 175 | } |
| 177 | - elseif (is_a($Agent, 'vCard')) |
|
| 176 | + elseif(is_a($Agent, 'vCard')) |
|
| 178 | 177 | { |
| 179 | 178 | echo '<div class="Agent">'; |
| 180 | 179 | OutputvCard($Agent); |
@@ -194,19 +193,19 @@ discard block |
||
| 194 | 193 | ) |
| 195 | 194 | ); |
| 196 | 195 | |
| 197 | - if (count($vCard) == 0) |
|
| 196 | + if(count($vCard) == 0) |
|
| 198 | 197 | { |
| 199 | 198 | throw new Exception('vCard test: empty vCard!'); |
| 200 | 199 | } |
| 201 | 200 | // if the file contains a single vCard, it is accessible directly. |
| 202 | - elseif (count($vCard) == 1) |
|
| 201 | + elseif(count($vCard) == 1) |
|
| 203 | 202 | { |
| 204 | 203 | OutputvCard($vCard); |
| 205 | 204 | } |
| 206 | 205 | // if the file contains multiple vCards, they are accessible as elements of an array |
| 207 | 206 | else |
| 208 | 207 | { |
| 209 | - foreach ($vCard as $Index => $vCardPart) |
|
| 208 | + foreach($vCard as $Index => $vCardPart) |
|
| 210 | 209 | { |
| 211 | 210 | OutputvCard($vCardPart); |
| 212 | 211 | } |
@@ -38,13 +38,13 @@ |
||
| 38 | 38 | // this is based on 1 => 1, 2 => 10, 3 => 11, 4 => 100, 5 => 101, 6 => 110, 7 => 111 |
| 39 | 39 | $fritz->doPostForm($formfields); |
| 40 | 40 | } |
| 41 | -catch (Exception $e) |
|
| 41 | +catch(Exception $e) |
|
| 42 | 42 | { |
| 43 | 43 | $message .= $e->getMessage(); |
| 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 | } |
@@ -38,13 +38,13 @@ |
||
| 38 | 38 | // this is based on 1 => 1, 2 => 10, 3 => 11, 4 => 100, 5 => 101, 6 => 110, 7 => 111 |
| 39 | 39 | $fritz->doPostForm($formfields); |
| 40 | 40 | } |
| 41 | -catch (Exception $e) |
|
| 41 | +catch(Exception $e) |
|
| 42 | 42 | { |
| 43 | 43 | $message .= $e->getMessage(); |
| 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 | } |
@@ -38,13 +38,13 @@ |
||
| 38 | 38 | // this is based on 1 => 1, 2 => 10, 3 => 11, 4 => 100, 5 => 101, 6 => 110, 7 => 111 |
| 39 | 39 | $fritz->doPostForm($formfields); |
| 40 | 40 | } |
| 41 | -catch (Exception $e) |
|
| 41 | +catch(Exception $e) |
|
| 42 | 42 | { |
| 43 | 43 | $message .= $e->getMessage(); |
| 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 | } |
@@ -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 | } |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | // set a log message |
| 55 | 55 | $message .= 'Call list sucessfully downloaded'; |
| 56 | 56 | } |
| 57 | -catch (Exception $e) |
|
| 57 | +catch(Exception $e) |
|
| 58 | 58 | { |
| 59 | 59 | $message .= $e->getMessage(); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // log the result |
| 63 | -if ( isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api' ) |
|
| 63 | +if(isset($fritz) && is_object($fritz) && get_class($fritz) == 'fritzbox_api') |
|
| 64 | 64 | { |
| 65 | 65 | $fritz->logMessage($message); |
| 66 | 66 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | if(isset($org_arr['name']) and $this->config['orgname']) |
| 264 | 264 | $orgname = trim($org_arr['name']); |
| 265 | 265 | |
| 266 | - if (isset($vcard_obj->fn[0])) |
|
| 266 | + if(isset($vcard_obj->fn[0])) |
|
| 267 | 267 | $formattedname = $vcard_obj->fn[0]; |
| 268 | 268 | |
| 269 | 269 | $firstname = trim($name_arr['firstname']); |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | if(array_key_exists('output_file', $this->config)) |
| 669 | 669 | { |
| 670 | 670 | // build md5 hash of previous stored xml without <mod_time> Elements |
| 671 | - $oldphonebhash = md5(preg_replace("/<mod_time>(\\d{10})/","",file_get_contents($this->config['output_file'],'r'),-1,$debugoldtsreplace)); |
|
| 671 | + $oldphonebhash = md5(preg_replace("/<mod_time>(\\d{10})/", "", file_get_contents($this->config['output_file'], 'r'), -1, $debugoldtsreplace)); |
|
| 672 | 672 | $output = fopen($this->config['output_file'], 'w'); |
| 673 | 673 | if($output) |
| 674 | 674 | { |
@@ -676,13 +676,13 @@ discard block |
||
| 676 | 676 | fclose($output); |
| 677 | 677 | print " Saved to file " . $this->config['output_file'] . PHP_EOL; |
| 678 | 678 | } |
| 679 | - if (array_key_exists('output_and_upload', $this->config) and $this->config['output_and_upload']) |
|
| 679 | + if(array_key_exists('output_and_upload', $this->config) and $this->config['output_and_upload']) |
|
| 680 | 680 | { |
| 681 | - $newphonebhash = md5(preg_replace("/<mod_time>(\\d{10})/","",file_get_contents($this->config['output_file'],'r'),-1,$debugnewtsreplace)); |
|
| 681 | + $newphonebhash = md5(preg_replace("/<mod_time>(\\d{10})/", "", file_get_contents($this->config['output_file'], 'r'), -1, $debugnewtsreplace)); |
|
| 682 | 682 | print " INFO: Compare old and new phonebook file versions." . PHP_EOL . " INFO: old version: " . $oldphonebhash . PHP_EOL . " INFO: new version: " . $newphonebhash . PHP_EOL; |
| 683 | 683 | if($oldphonebhash === $newphonebhash) |
| 684 | 684 | { |
| 685 | - print " INFO: Same versions ==> No changes in phonebook or images" . PHP_EOL . " EXIT: No need to upload phonebook to the FRITZ!Box.". PHP_EOL; |
|
| 685 | + print " INFO: Same versions ==> No changes in phonebook or images" . PHP_EOL . " EXIT: No need to upload phonebook to the FRITZ!Box." . PHP_EOL; |
|
| 686 | 686 | return 0; |
| 687 | 687 | } |
| 688 | 688 | else |