@@ -47,14 +47,11 @@ discard block |
||
| 47 | 47 | $i = strlen($i); |
| 48 | 48 | if ($i <= 127) { |
| 49 | 49 | $res = pack('C', $i); |
| 50 | - } |
|
| 51 | - elseif ($i <= 255) { |
|
| 50 | + } elseif ($i <= 255) { |
|
| 52 | 51 | $res = pack('CC', 0x81, $i); |
| 53 | - } |
|
| 54 | - elseif ($i <= 65535) { |
|
| 52 | + } elseif ($i <= 65535) { |
|
| 55 | 53 | $res = pack('Cn', 0x82, $i); |
| 56 | - } |
|
| 57 | - else { |
|
| 54 | + } else { |
|
| 58 | 55 | $res = pack('CN', 0x84, $i); |
| 59 | 56 | } |
| 60 | 57 | |
@@ -163,8 +160,7 @@ discard block |
||
| 163 | 160 | $this->xtns->next(); |
| 164 | 161 | if ($choice == 1) { |
| 165 | 162 | $res['responderID']['byName'] = $this->xtns->name(); |
| 166 | - } |
|
| 167 | - elseif ($choice == 2) { |
|
| 163 | + } elseif ($choice == 2) { |
|
| 168 | 164 | $res['responderID']['byKey'] = $this->xtns->keyident(); |
| 169 | 165 | } |
| 170 | 166 | $res['producedAt'] = $this->xtns->time(); |
@@ -495,14 +495,11 @@ |
||
| 495 | 495 | $i = strlen($i); |
| 496 | 496 | if ($i <= 127) { |
| 497 | 497 | $res = pack('C', $i); |
| 498 | - } |
|
| 499 | - elseif ($i <= 255) { |
|
| 498 | + } elseif ($i <= 255) { |
|
| 500 | 499 | $res = pack('CC', 0x81, $i); |
| 501 | - } |
|
| 502 | - elseif ($i <= 65535) { |
|
| 500 | + } elseif ($i <= 65535) { |
|
| 503 | 501 | $res = pack('Cn', 0x82, $i); |
| 504 | - } |
|
| 505 | - else { |
|
| 502 | + } else { |
|
| 506 | 503 | $res = pack('CN', 0x84, $i); |
| 507 | 504 | } |
| 508 | 505 | |
@@ -77,17 +77,13 @@ discard block |
||
| 77 | 77 | $int = bcadd($int, ord($byte), 0); |
| 78 | 78 | } |
| 79 | 79 | $this->value = $int; |
| 80 | - } |
|
| 81 | - elseif ($this->tag == 1) { # boolean |
|
| 80 | + } elseif ($this->tag == 1) { # boolean |
|
| 82 | 81 | $this->value = ord($value) != 0; |
| 83 | - } |
|
| 84 | - elseif ($this->tag == 3) { # bit string |
|
| 82 | + } elseif ($this->tag == 3) { # bit string |
|
| 85 | 83 | $this->value = $value; |
| 86 | - } |
|
| 87 | - elseif ($this->tag == 5) { # null |
|
| 84 | + } elseif ($this->tag == 5) { # null |
|
| 88 | 85 | $this->value = null; |
| 89 | - } |
|
| 90 | - else { |
|
| 86 | + } else { |
|
| 91 | 87 | $this->value = $value; |
| 92 | 88 | } |
| 93 | 89 | } |
@@ -102,8 +98,7 @@ discard block |
||
| 102 | 98 | $i = $this->i; |
| 103 | 99 | if (!$pass) { |
| 104 | 100 | $this->i = $oldi; |
| 105 | - } |
|
| 106 | - else { |
|
| 101 | + } else { |
|
| 107 | 102 | $this->i += $this->len; |
| 108 | 103 | } |
| 109 | 104 | |
@@ -181,15 +176,12 @@ discard block |
||
| 181 | 176 | try { |
| 182 | 177 | if (method_exists($this, $extnID)) { |
| 183 | 178 | $theext['extnValue'] = call_user_func([$this, $extnID], $theext['extnValue']); |
| 184 | - } |
|
| 185 | - elseif (!empty($ignoredextensions['$extnID'])) { |
|
| 179 | + } elseif (!empty($ignoredextensions['$extnID'])) { |
|
| 186 | 180 | trigger_error("Unknown extension {$extnID}", E_USER_ERROR); |
| 187 | - } |
|
| 188 | - else { |
|
| 181 | + } else { |
|
| 189 | 182 | $theext['extnValue'] = chunk_split(bin2hex($theext['extnValue']), 2, ':'); |
| 190 | 183 | } |
| 191 | - } |
|
| 192 | - catch (\Exception $e) { |
|
| 184 | + } catch (\Exception $e) { |
|
| 193 | 185 | $theext['extnValue'] = chunk_split(bin2hex($theext['extnValue']), 2, ':'); |
| 194 | 186 | } |
| 195 | 187 | $this->end(); |
@@ -259,8 +251,7 @@ discard block |
||
| 259 | 251 | $time = $this->next($tag); |
| 260 | 252 | if ($this->tag == 23) { |
| 261 | 253 | $time = (substr($time, 0, 2) < 50 ? '20' : '19') . $time; |
| 262 | - } |
|
| 263 | - elseif ($this->tag != 24) { |
|
| 254 | + } elseif ($this->tag != 24) { |
|
| 264 | 255 | trigger_error('expected der utc or generalized time', E_USER_ERROR); |
| 265 | 256 | } |
| 266 | 257 | |
@@ -86,8 +86,7 @@ discard block |
||
| 86 | 86 | default: |
| 87 | 87 | $this->handleUnknownActionType($actionType); |
| 88 | 88 | } |
| 89 | - } |
|
| 90 | - catch (Exception $e) { |
|
| 89 | + } catch (Exception $e) { |
|
| 91 | 90 | $this->sendFeedback(false, parent::errorDetailsFromException($e)); |
| 92 | 91 | } |
| 93 | 92 | } |
@@ -116,8 +115,7 @@ discard block |
||
| 116 | 115 | // No certificates |
| 117 | 116 | if (!$privateCerts || count($privateCerts) === 0) { |
| 118 | 117 | $message = _('No certificate avaliable'); |
| 119 | - } |
|
| 120 | - else { |
|
| 118 | + } else { |
|
| 121 | 119 | // For each certificate in MAPI store |
| 122 | 120 | $smtpAddress = $GLOBALS['mapisession']->getSMTPAddress(); |
| 123 | 121 | for ($i = 0, $cnt = count($privateCerts); $i < $cnt; ++$i) { |
@@ -126,14 +124,11 @@ discard block |
||
| 126 | 124 | // And remove possible duplication from plugin.smime.php->onUploadCertificate |
| 127 | 125 | if ($privateCerts[$i][PR_MESSAGE_DELIVERY_TIME] < time()) { // validTo |
| 128 | 126 | $message = _('Private certificate is not valid yet, unable to sign email'); |
| 129 | - } |
|
| 130 | - elseif ($privateCerts[$i][PR_CLIENT_SUBMIT_TIME] >= time()) { // validFrom |
|
| 127 | + } elseif ($privateCerts[$i][PR_CLIENT_SUBMIT_TIME] >= time()) { // validFrom |
|
| 131 | 128 | $message = _('Private certificate has been expired, unable to sign email'); |
| 132 | - } |
|
| 133 | - elseif (strcasecmp($privateCerts[$i][PR_SUBJECT], $smtpAddress) !== 0) { |
|
| 129 | + } elseif (strcasecmp($privateCerts[$i][PR_SUBJECT], $smtpAddress) !== 0) { |
|
| 134 | 130 | $message = _('Private certificate does not match email address'); |
| 135 | - } |
|
| 136 | - else { |
|
| 131 | + } else { |
|
| 137 | 132 | $status = true; |
| 138 | 133 | $message = ''; |
| 139 | 134 | $certIdx = $i; |
@@ -167,15 +162,13 @@ discard block |
||
| 167 | 162 | $encryptionStore = EncryptionStore::getInstance(); |
| 168 | 163 | if (encryptionStoreExpirationSupport()) { |
| 169 | 164 | $encryptionStore->add('smime', $data['passphrase'], time() + (5 * 60)); |
| 170 | - } |
|
| 171 | - else { |
|
| 165 | + } else { |
|
| 172 | 166 | withPHPSession(function () use ($encryptionStore, $data) { |
| 173 | 167 | $encryptionStore->add('smime', $data['passphrase']); |
| 174 | 168 | }); |
| 175 | 169 | } |
| 176 | 170 | $result = true; |
| 177 | - } |
|
| 178 | - else { |
|
| 171 | + } else { |
|
| 179 | 172 | $result = false; |
| 180 | 173 | } |
| 181 | 174 | |
@@ -64,8 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if (version_compare(phpversion(), '5.4', '<')) { |
| 66 | 66 | $this->cipher = OPENSSL_CIPHER_3DES; |
| 67 | - } |
|
| 68 | - else { |
|
| 67 | + } else { |
|
| 69 | 68 | $this->cipher = PLUGIN_SMIME_CIPHER; |
| 70 | 69 | } |
| 71 | 70 | } |
@@ -188,8 +187,7 @@ discard block |
||
| 188 | 187 | |
| 189 | 188 | if (array_filter($missingCerts, "missingMyself") === []) { |
| 190 | 189 | $errorMsg = _('Missing public certificates for the following recipients: ') . implode(', ', $missingCerts) . _('. Please contact your system administrator for details'); |
| 191 | - } |
|
| 192 | - else { |
|
| 190 | + } else { |
|
| 193 | 191 | $errorMsg = _("Your public certificate is not installed. Without this certificate, you will not be able to read encrypted messages you have sent to others."); |
| 194 | 192 | } |
| 195 | 193 | |
@@ -225,8 +223,7 @@ discard block |
||
| 225 | 223 | // Put empty string into file? dafuq? |
| 226 | 224 | file_put_contents($tmpUserCert, $userCert); |
| 227 | 225 | } |
| 228 | - } |
|
| 229 | - catch (MAPIException $e) { |
|
| 226 | + } catch (MAPIException $e) { |
|
| 230 | 227 | $msg = "[smime] Unable to open PR_SENT_REPRESENTING_ENTRYID. Maybe %s was does not exists or deleted from server."; |
| 231 | 228 | Log::write(LOGLEVEL_ERROR, sprintf($msg, $userProps[PR_SENT_REPRESENTING_NAME])); |
| 232 | 229 | error_log("[smime] Unable to open PR_SENT_REPRESENTING_NAME: " . print_r($userProps[PR_SENT_REPRESENTING_NAME], true)); |
@@ -242,8 +239,7 @@ discard block |
||
| 242 | 239 | $senderAddressArray = $senderAddressArray['props']; |
| 243 | 240 | if ($senderAddressArray['address_type'] === 'SMTP') { |
| 244 | 241 | $emailAddr = $senderAddressArray['email_address']; |
| 245 | - } |
|
| 246 | - else { |
|
| 242 | + } else { |
|
| 247 | 243 | $emailAddr = $senderAddressArray['smtp_address']; |
| 248 | 244 | } |
| 249 | 245 | |
@@ -253,8 +249,7 @@ discard block |
||
| 253 | 249 | if (!$emailAddr) { |
| 254 | 250 | if (!empty($userProps[PR_SENT_REPRESENTING_NAME])) { |
| 255 | 251 | $emailAddr = $userProps[PR_SENT_REPRESENTING_NAME]; |
| 256 | - } |
|
| 257 | - else { |
|
| 252 | + } else { |
|
| 258 | 253 | $searchKeys = mapi_getprops($message, [PR_SEARCH_KEY, PR_SENT_REPRESENTING_SEARCH_KEY]); |
| 259 | 254 | $searchKey = $searchKeys[PR_SEARCH_KEY] ?? $searchKeys[PR_SENT_REPRESENTING_SEARCH_KEY]; |
| 260 | 255 | if ($searchKey) { |
@@ -307,16 +302,14 @@ discard block |
||
| 307 | 302 | $importMessageCert !== false) { |
| 308 | 303 | // Redundant |
| 309 | 304 | $importMessageCert = true; |
| 310 | - } |
|
| 311 | - else { |
|
| 305 | + } else { |
|
| 312 | 306 | $importMessageCert = false; |
| 313 | 307 | verifyOCSP($userCert, $caCerts, $this->message); |
| 314 | 308 | break; |
| 315 | 309 | } |
| 316 | 310 | } |
| 317 | 311 | } |
| 318 | - } |
|
| 319 | - else { |
|
| 312 | + } else { |
|
| 320 | 313 | // Works. Just leave it. |
| 321 | 314 | $signed_ok = openssl_pkcs7_verify($tmpfname, PKCS7_NOSIGS, $outcert, explode(';', PLUGIN_SMIME_CACERTS)); |
| 322 | 315 | $openssl_error_code = $this->extract_openssl_error(); |
@@ -333,8 +326,7 @@ discard block |
||
| 333 | 326 | } |
| 334 | 327 | // We don't have a certificate from the MAPI UserStore or LDAP, so we will set $userCert to $importCert |
| 335 | 328 | // so that we can verify the message according to the be imported certificate. |
| 336 | - } |
|
| 337 | - else { // No pubkey |
|
| 329 | + } else { // No pubkey |
|
| 338 | 330 | $importMessageCert = false; |
| 339 | 331 | Log::write(LOGLEVEL_INFO, sprintf("[smime] Unable to verify message without public key, openssl error: '%s'", $this->openssl_error)); |
| 340 | 332 | $this->message['success'] = SMIME_STATUS_FAIL; |
@@ -404,8 +396,7 @@ discard block |
||
| 404 | 396 | break; |
| 405 | 397 | } |
| 406 | 398 | } |
| 407 | - } |
|
| 408 | - else { |
|
| 399 | + } else { |
|
| 409 | 400 | $decryptStatus = openssl_pkcs7_decrypt($tmpFile, $tmpDecrypted, $certs['cert'], [$certs['pkey'], $pass]); |
| 410 | 401 | } |
| 411 | 402 | |
@@ -437,19 +428,16 @@ discard block |
||
| 437 | 428 | if (strpos($content, 'multipart/signed') !== false || strpos($content, 'signed-data') !== false) { |
| 438 | 429 | $this->message['type'] = 'encryptsigned'; |
| 439 | 430 | $this->verifyMessage($data['message'], $content); |
| 440 | - } |
|
| 441 | - elseif ($decryptStatus) { |
|
| 431 | + } elseif ($decryptStatus) { |
|
| 442 | 432 | $this->message['info'] = SMIME_DECRYPT_SUCCESS; |
| 443 | 433 | $this->message['success'] = SMIME_STATUS_SUCCESS; |
| 444 | - } |
|
| 445 | - elseif ($this->extract_openssl_error() === OPENSSL_RECIPIENT_CERTIFICATE_MISMATCH) { |
|
| 434 | + } elseif ($this->extract_openssl_error() === OPENSSL_RECIPIENT_CERTIFICATE_MISMATCH) { |
|
| 446 | 435 | error_log("[smime] Error when decrypting email, openssl error: " . print_r($this->openssl_error, true)); |
| 447 | 436 | Log::Write(LOGLEVEL_ERROR, sprintf("[smime] Error when decrypting email, openssl error: '%s'", $this->openssl_error)); |
| 448 | 437 | $this->message['info'] = SMIME_DECRYPT_CERT_MISMATCH; |
| 449 | 438 | $this->message['success'] = SMIME_STATUS_FAIL; |
| 450 | 439 | } |
| 451 | - } |
|
| 452 | - else { |
|
| 440 | + } else { |
|
| 453 | 441 | $this->message['info'] = SMIME_UNLOCK_CERT; |
| 454 | 442 | } |
| 455 | 443 | |
@@ -482,18 +470,15 @@ discard block |
||
| 482 | 470 | $this->message['info'] = SMIME_ERROR; |
| 483 | 471 | $this->message['success'] = SMIME_STATUS_FAIL; |
| 484 | 472 | // Verification was successful |
| 485 | - } |
|
| 486 | - elseif ($openssl_return) { |
|
| 473 | + } elseif ($openssl_return) { |
|
| 487 | 474 | $this->message['info'] = SMIME_SUCCESS; |
| 488 | 475 | $this->message['success'] = SMIME_STATUS_SUCCESS; |
| 489 | 476 | // Verification was not successful, display extra information. |
| 490 | - } |
|
| 491 | - else { |
|
| 477 | + } else { |
|
| 492 | 478 | $this->message['success'] = SMIME_STATUS_FAIL; |
| 493 | 479 | if ($openssl_errors === OPENSSL_CA_VERIFY_FAIL) { |
| 494 | 480 | $this->message['info'] = SMIME_CA; |
| 495 | - } |
|
| 496 | - else { // Catch general errors |
|
| 481 | + } else { // Catch general errors |
|
| 497 | 482 | $this->message['info'] = SMIME_ERROR; |
| 498 | 483 | } |
| 499 | 484 | } |
@@ -542,8 +527,7 @@ discard block |
||
| 542 | 527 | // TODO: update to serialNumber check |
| 543 | 528 | if ($certMessage && $certMessage[0][PR_MESSAGE_DELIVERY_TIME] == $publickeyData['validTo_time_t']) { |
| 544 | 529 | $message = _('Certificate is already stored on the server'); |
| 545 | - } |
|
| 546 | - else { |
|
| 530 | + } else { |
|
| 547 | 531 | $saveCert = true; |
| 548 | 532 | $root = mapi_msgstore_openentry($this->getStore(), null); |
| 549 | 533 | // Remove old certificate |
@@ -619,8 +603,7 @@ discard block |
||
| 619 | 603 | if (isset($props[PR_EC_IMAP_EMAIL]) || propIsError(PR_EC_IMAP_EMAIL, $props) == MAPI_E_NOT_ENOUGH_MEMORY) { |
| 620 | 604 | // Stream the message to properly get the PR_EC_IMAP_EMAIL property |
| 621 | 605 | $emlMessageStream = mapi_openproperty($message, PR_EC_IMAP_EMAIL, IID_IStream, 0, 0); |
| 622 | - } |
|
| 623 | - else { |
|
| 606 | + } else { |
|
| 624 | 607 | // Read the message as RFC822-formatted e-mail stream. |
| 625 | 608 | $emlMessageStream = mapi_inetmapi_imtoinet($GLOBALS['mapisession']->getSession(), $GLOBALS['mapisession']->getAddressbook(), $message, []); |
| 626 | 609 | } |
@@ -725,8 +708,7 @@ discard block |
||
| 725 | 708 | Log::Write(LOGLEVEL_ERROR, sprintf("[smime] Unable to sign message with intermediate certificates, openssl error: '%s'", @openssl_error_string())); |
| 726 | 709 | } |
| 727 | 710 | unlink($tmpFile); |
| 728 | - } |
|
| 729 | - else { |
|
| 711 | + } else { |
|
| 730 | 712 | $ok = openssl_pkcs7_sign($infile, $outfile, $certs['cert'], [$certs['pkey'], ''], [], PKCS7_DETACHED); |
| 731 | 713 | if (!$ok) { |
| 732 | 714 | Log::Write(LOGLEVEL_ERROR, sprintf("[smime] Unable to sign message, openssl error: '%s'", @openssl_error_string())); |
@@ -830,8 +812,7 @@ discard block |
||
| 830 | 812 | |
| 831 | 813 | if (!empty($gabCert)) { |
| 832 | 814 | array_push($publicCerts, $gabCert); |
| 833 | - } |
|
| 834 | - elseif (!empty($storeCert)) { |
|
| 815 | + } elseif (!empty($storeCert)) { |
|
| 835 | 816 | array_push($publicCerts, base64_decode($storeCert)); |
| 836 | 817 | } |
| 837 | 818 | } |
@@ -963,8 +944,7 @@ discard block |
||
| 963 | 944 | if ($php72) { |
| 964 | 945 | openssl_pkcs7_verify($emlfile, PKCS7_NOVERIFY, $certfile); |
| 965 | 946 | openssl_pkcs7_verify($emlfile, PKCS7_NOVERIFY, $certfile, [], $certfile, $outfile, $p7bfile); |
| 966 | - } |
|
| 967 | - else { |
|
| 947 | + } else { |
|
| 968 | 948 | kopano_pkcs7_verify($emlfile, PKCS7_NOVERIFY, $certfile); |
| 969 | 949 | kopano_pkcs7_verify($emlfile, PKCS7_NOVERIFY, $certfile, [], $certfile, $outfile, $p7bfile); |
| 970 | 950 | } |
@@ -973,8 +953,7 @@ discard block |
||
| 973 | 953 | $p7b = file_get_contents($p7bfile); |
| 974 | 954 | if ($php72) { |
| 975 | 955 | openssl_pkcs7_read($p7b, $cas); |
| 976 | - } |
|
| 977 | - else { |
|
| 956 | + } else { |
|
| 978 | 957 | // FIXME: Without the error_log, kopano_pkcs7_verify does not work (wtf). |
| 979 | 958 | error_log($p7b); |
| 980 | 959 | kopano_pkcs7_read($p7b, $cas); |
@@ -1045,8 +1024,7 @@ discard block |
||
| 1045 | 1024 | |
| 1046 | 1025 | if ($hash === 'sha1') { |
| 1047 | 1026 | $fingerprint = sha1($body); |
| 1048 | - } |
|
| 1049 | - else { |
|
| 1027 | + } else { |
|
| 1050 | 1028 | $fingerprint = md5($body); |
| 1051 | 1029 | } |
| 1052 | 1030 | |
@@ -1071,8 +1049,7 @@ discard block |
||
| 1071 | 1049 | try { |
| 1072 | 1050 | $user = mapi_ab_resolvename($addrbook, $userArr, EMS_AB_ADDRESS_LOOKUP); |
| 1073 | 1051 | $user = mapi_ab_openentry($addrbook, $user[0][PR_ENTRYID]); |
| 1074 | - } |
|
| 1075 | - catch (MAPIException $e) { |
|
| 1052 | + } catch (MAPIException $e) { |
|
| 1076 | 1053 | $e->setHandled(); |
| 1077 | 1054 | } |
| 1078 | 1055 | |
@@ -1145,8 +1122,7 @@ discard block |
||
| 1145 | 1122 | $senderStructure["props"]['display_type'] = isset($userprops[PR_DISPLAY_TYPE]) ? $userprops[PR_DISPLAY_TYPE] : MAPI_MAILUSER; |
| 1146 | 1123 | $senderStructure["props"]['display_type_ex'] = isset($userprops[PR_DISPLAY_TYPE_EX]) ? $userprops[PR_DISPLAY_TYPE_EX] : MAPI_MAILUSER; |
| 1147 | 1124 | } |
| 1148 | - } |
|
| 1149 | - catch (MAPIException $e) { |
|
| 1125 | + } catch (MAPIException $e) { |
|
| 1150 | 1126 | Log::write(LOGLEVEL_ERROR, sprintf("%s %s", $e, $userProps[PR_SENT_REPRESENTING_NAME])); |
| 1151 | 1127 | } |
| 1152 | 1128 | |
@@ -122,8 +122,7 @@ discard block |
||
| 122 | 122 | // If subject/emailAddress is not set, try subjectAltName |
| 123 | 123 | if (isset($this->data['subject']['emailAddress'])) { |
| 124 | 124 | $certEmailAddress = $this->data['subject']['emailAddress']; |
| 125 | - } |
|
| 126 | - elseif (isset($this->data['extensions'], $this->data['extensions']['subjectAltName']) |
|
| 125 | + } elseif (isset($this->data['extensions'], $this->data['extensions']['subjectAltName']) |
|
| 127 | 126 | ) { |
| 128 | 127 | // Example [subjectAltName] => email:[email protected] |
| 129 | 128 | $tmp = explode('email:', $this->data['extensions']['subjectAltName']); |
@@ -242,8 +241,7 @@ discard block |
||
| 242 | 241 | $body = base64_decode($body); |
| 243 | 242 | if ($hash_algorithm === 'sha1') { |
| 244 | 243 | $fingerprint = sha1($body); |
| 245 | - } |
|
| 246 | - else { |
|
| 244 | + } else { |
|
| 247 | 245 | $fingerprint = md5($body); |
| 248 | 246 | } |
| 249 | 247 | // Format 1000AB as 10:00:AB |
@@ -281,8 +279,7 @@ discard block |
||
| 281 | 279 | $curl_error = curl_error($ch); |
| 282 | 280 | if (!$curl_error && $http_status === 200) { |
| 283 | 281 | $cert = $this->der2pem($output); |
| 284 | - } |
|
| 285 | - else { |
|
| 282 | + } else { |
|
| 286 | 283 | Log::Write(LOGLEVEL_ERROR, sprintf("[smime] Error when downloading internmediate certificate '%s', http status: '%s'", $curl_error, $http_status)); |
| 287 | 284 | } |
| 288 | 285 | curl_close($ch); |
@@ -17,8 +17,7 @@ discard block |
||
| 17 | 17 | // If subject/emailAddress is not set, try subjectAltName |
| 18 | 18 | if (isset($certificate['subject']['emailAddress'])) { |
| 19 | 19 | $certEmailAddress = $certificate['subject']['emailAddress']; |
| 20 | - } |
|
| 21 | - elseif (isset($certificate['extensions'], $certificate['extensions']['subjectAltName'])) { |
|
| 20 | + } elseif (isset($certificate['extensions'], $certificate['extensions']['subjectAltName'])) { |
|
| 22 | 21 | // Example [subjectAltName] => email:[email protected] |
| 23 | 22 | $tmp = explode('email:', $certificate['extensions']['subjectAltName']); |
| 24 | 23 | // Only get the first match |
@@ -183,8 +182,7 @@ discard block |
||
| 183 | 182 | if ($issuer->issuer()) { |
| 184 | 183 | $issuer->verify(); |
| 185 | 184 | } |
| 186 | - } |
|
| 187 | - catch (OCSPException $e) { |
|
| 185 | + } catch (OCSPException $e) { |
|
| 188 | 186 | if ($e->getCode() === OCSP_CERT_STATUS && $e->getCertStatus() == OCSP_CERT_STATUS_REVOKED) { |
| 189 | 187 | $message['info'] = SMIME_REVOKED; |
| 190 | 188 | $message['success'] = SMIME_STATUS_PARTIAL; |
@@ -244,8 +242,7 @@ discard block |
||
| 244 | 242 | elseif (!verifyOCSP($certs['cert'], $extracerts, $data)) { |
| 245 | 243 | $message = _('Certificate is revoked'); |
| 246 | 244 | } |
| 247 | - } |
|
| 248 | - else { // Can't parse public certificate pkcs#12 file might be corrupt |
|
| 245 | + } else { // Can't parse public certificate pkcs#12 file might be corrupt |
|
| 249 | 246 | $message = _('Unable to read public certificate'); |
| 250 | 247 | } |
| 251 | 248 | |
@@ -87,8 +87,7 @@ discard block |
||
| 87 | 87 | // Add file into zip by stream |
| 88 | 88 | $zip->addFromString($filename, $datastring); |
| 89 | 89 | } |
| 90 | - } |
|
| 91 | - else { |
|
| 90 | + } else { |
|
| 92 | 91 | $zip->close(); |
| 93 | 92 | // Remove the zip file to avoid unnecessary disk-space consumption |
| 94 | 93 | unlink($randomZipName); |
@@ -135,8 +134,7 @@ discard block |
||
| 135 | 134 | if (isset($messageProps[PR_EC_IMAP_EMAIL]) || propIsError(PR_EC_IMAP_EMAIL, $messageProps) == MAPI_E_NOT_ENOUGH_MEMORY) { |
| 136 | 135 | // Stream the message to properly get the PR_EC_IMAP_EMAIL property |
| 137 | 136 | $stream = mapi_openproperty($this->message, PR_EC_IMAP_EMAIL, IID_IStream, 0, 0); |
| 138 | - } |
|
| 139 | - else { |
|
| 137 | + } else { |
|
| 140 | 138 | // Get addressbook for current session |
| 141 | 139 | $addrBook = $GLOBALS['mapisession']->getAddressbook(); |
| 142 | 140 | |
@@ -155,8 +153,7 @@ discard block |
||
| 155 | 153 | if ($this->allAsZip) { |
| 156 | 154 | // download multiple eml messages in a ZIP file |
| 157 | 155 | $this->downloadMessageAsZipFile(); |
| 158 | - } |
|
| 159 | - else { |
|
| 156 | + } else { |
|
| 160 | 157 | // download message as file |
| 161 | 158 | $this->downloadMessageAsFile(); |
| 162 | 159 | } |
@@ -172,7 +169,6 @@ discard block |
||
| 172 | 169 | |
| 173 | 170 | // download message |
| 174 | 171 | $messageInstance->download(); |
| 175 | -} |
|
| 176 | -catch (Exception $e) { |
|
| 172 | +} catch (Exception $e) { |
|
| 177 | 173 | $messageInstance->handleSaveMessageException($e); |
| 178 | 174 | } |
@@ -151,8 +151,7 @@ discard block |
||
| 151 | 151 | if (!isIE11() && !isEdge() && $this->ignoreExtractAttachid === false) { |
| 152 | 152 | $attachID = substr($filename, -8); |
| 153 | 153 | $filename = substr($filename, 0, -8); |
| 154 | - } |
|
| 155 | - else { |
|
| 154 | + } else { |
|
| 156 | 155 | $attachID = uniqid(); |
| 157 | 156 | } |
| 158 | 157 | |
@@ -178,8 +177,7 @@ discard block |
||
| 178 | 177 | // import given files |
| 179 | 178 | if ($this->import) { |
| 180 | 179 | $importStatus = $this->importFiles($attachTempName, $filename, isset($_POST['has_icsvcs_file']) ? $_POST['has_icsvcs_file'] : false); |
| 181 | - } |
|
| 182 | - elseif ($sourcetype === 'contactphoto' || $sourcetype === 'default') { |
|
| 180 | + } elseif ($sourcetype === 'contactphoto' || $sourcetype === 'default') { |
|
| 183 | 181 | $fileData = [ |
| 184 | 182 | 'props' => [ |
| 185 | 183 | 'attach_num' => -1, |
@@ -195,8 +193,7 @@ discard block |
||
| 195 | 193 | } |
| 196 | 194 | |
| 197 | 195 | $returnfiles[] = $fileData; |
| 198 | - } |
|
| 199 | - else { |
|
| 196 | + } else { |
|
| 200 | 197 | // Backwards compatibility for Plugins (S/MIME) |
| 201 | 198 | $lastKey = count($returnfiles) - 1; |
| 202 | 199 | if ($lastKey >= 0) { |
@@ -209,12 +206,10 @@ discard block |
||
| 209 | 206 | if ($this->import) { |
| 210 | 207 | if ($importStatus !== false) { |
| 211 | 208 | $this->sendImportResponse($importStatus); |
| 212 | - } |
|
| 213 | - else { |
|
| 209 | + } else { |
|
| 214 | 210 | throw new ZarafaException(_("File is not imported successfully")); |
| 215 | 211 | } |
| 216 | - } |
|
| 217 | - else { |
|
| 212 | + } else { |
|
| 218 | 213 | $return = [ |
| 219 | 214 | 'success' => true, |
| 220 | 215 | 'zarafa' => [ |
@@ -294,21 +289,18 @@ discard block |
||
| 294 | 289 | processVCFStream($attachmentStream); |
| 295 | 290 | // Convert vCard 1.0 to a MAPI contact. |
| 296 | 291 | $contacts = $this->convertVCFContactsToMapi($this->destinationFolder, $attachmentStream); |
| 297 | - } |
|
| 298 | - catch (ZarafaException $e) { |
|
| 292 | + } catch (ZarafaException $e) { |
|
| 299 | 293 | $e->setTitle(_("Import error")); |
| 300 | 294 | |
| 301 | 295 | throw $e; |
| 302 | - } |
|
| 303 | - catch (Exception $e) { |
|
| 296 | + } catch (Exception $e) { |
|
| 304 | 297 | $destinationFolderProps = mapi_getprops($this->destinationFolder, [PR_DISPLAY_NAME, PR_MDB_PROVIDER]); |
| 305 | 298 | $fullyQualifiedFolderName = $destinationFolderProps[PR_DISPLAY_NAME]; |
| 306 | 299 | if ($destinationFolderProps[PR_MDB_PROVIDER] === ZARAFA_STORE_PUBLIC_GUID) { |
| 307 | 300 | $publicStore = $GLOBALS["mapisession"]->getPublicMessageStore(); |
| 308 | 301 | $publicStoreName = mapi_getprops($publicStore, [PR_DISPLAY_NAME]); |
| 309 | 302 | $fullyQualifiedFolderName .= " - " . $publicStoreName[PR_DISPLAY_NAME]; |
| 310 | - } |
|
| 311 | - elseif ($destinationFolderProps[PR_MDB_PROVIDER] === ZARAFA_STORE_DELEGATE_GUID) { |
|
| 303 | + } elseif ($destinationFolderProps[PR_MDB_PROVIDER] === ZARAFA_STORE_DELEGATE_GUID) { |
|
| 312 | 304 | $otherStore = $GLOBALS['operations']->getOtherStoreFromEntryid($this->destinationFolderId); |
| 313 | 305 | $sharedStoreOwnerName = mapi_getprops($otherStore, [PR_MAILBOX_OWNER_NAME]); |
| 314 | 306 | $fullyQualifiedFolderName .= " - " . $sharedStoreOwnerName[PR_MAILBOX_OWNER_NAME]; |
@@ -317,14 +309,11 @@ discard block |
||
| 317 | 309 | $message = sprintf(_("Unable to import '%s' to '%s'. "), $filename, $fullyQualifiedFolderName); |
| 318 | 310 | if ($e->getCode() === MAPI_E_TABLE_EMPTY) { |
| 319 | 311 | $message .= _("There is no contact found in this file."); |
| 320 | - } |
|
| 321 | - elseif ($e->getCode() === MAPI_E_CORRUPT_DATA) { |
|
| 312 | + } elseif ($e->getCode() === MAPI_E_CORRUPT_DATA) { |
|
| 322 | 313 | $message .= _("The file is corrupt."); |
| 323 | - } |
|
| 324 | - elseif ($e->getCode() === MAPI_E_INVALID_PARAMETER) { |
|
| 314 | + } elseif ($e->getCode() === MAPI_E_INVALID_PARAMETER) { |
|
| 325 | 315 | $message .= _("The file is invalid."); |
| 326 | - } |
|
| 327 | - else { |
|
| 316 | + } else { |
|
| 328 | 317 | $message = sprintf(_("Unable to import '%s'. "), $filename) . _("Please contact your system administrator if the problem persists."); |
| 329 | 318 | } |
| 330 | 319 | |
@@ -367,16 +356,14 @@ discard block |
||
| 367 | 356 | // but if it doesn't exist, we use the old function 'mapi_vcftomapi' for single vcf file. |
| 368 | 357 | if (function_exists('mapi_vcftomapi2')) { |
| 369 | 358 | $contacts = mapi_vcftomapi2($destinationFolder, $attachmentStream); |
| 370 | - } |
|
| 371 | - elseif ($_POST['is_single_import']) { |
|
| 359 | + } elseif ($_POST['is_single_import']) { |
|
| 372 | 360 | $newMessage = mapi_folder_createmessage($this->destinationFolder); |
| 373 | 361 | $store = $GLOBALS["mapisession"]->getDefaultMessageStore(); |
| 374 | 362 | $ok = mapi_vcftomapi($GLOBALS['mapisession']->getSession(), $store, $newMessage, $attachmentStream); |
| 375 | 363 | if ($ok !== false) { |
| 376 | 364 | $contacts = is_array($newMessage) ? $newMessage : [$newMessage]; |
| 377 | 365 | } |
| 378 | - } |
|
| 379 | - else { |
|
| 366 | + } else { |
|
| 380 | 367 | // Throw error related to multiple vcf as the function is not available for importing multiple vcf file. |
| 381 | 368 | throw new ZarafaException(_("grommunio Web does not support importing multiple VCF with this version.")); |
| 382 | 369 | } |
@@ -439,8 +426,7 @@ discard block |
||
| 439 | 426 | if (array_search($value, $prefix, true) !== false) { |
| 440 | 427 | $props[PR_DISPLAY_NAME_PREFIX] = $value; |
| 441 | 428 | unset($str[$index]); |
| 442 | - } |
|
| 443 | - elseif (array_search($value, $suffix, true) !== false) { |
|
| 429 | + } elseif (array_search($value, $suffix, true) !== false) { |
|
| 444 | 430 | $props[PR_GENERATION] = $value; |
| 445 | 431 | unset($str[$index]); |
| 446 | 432 | } |
@@ -486,13 +472,11 @@ discard block |
||
| 486 | 472 | |
| 487 | 473 | try { |
| 488 | 474 | $events = $this->convertICSToMapi($attachmentStream); |
| 489 | - } |
|
| 490 | - catch (ZarafaException $e) { |
|
| 475 | + } catch (ZarafaException $e) { |
|
| 491 | 476 | $e->setTitle(_("Import error")); |
| 492 | 477 | |
| 493 | 478 | throw $e; |
| 494 | - } |
|
| 495 | - catch (Exception $e) { |
|
| 479 | + } catch (Exception $e) { |
|
| 496 | 480 | $destinationFolderProps = mapi_getprops($this->destinationFolder, [PR_DISPLAY_NAME, PR_MDB_PROVIDER]); |
| 497 | 481 | $fullyQualifiedFolderName = $destinationFolderProps[PR_DISPLAY_NAME]; |
| 498 | 482 | // Condition true if folder is belongs to Public store. |
@@ -500,8 +484,7 @@ discard block |
||
| 500 | 484 | $publicStore = $GLOBALS["mapisession"]->getPublicMessageStore(); |
| 501 | 485 | $publicStoreName = mapi_getprops($publicStore, [PR_DISPLAY_NAME]); |
| 502 | 486 | $fullyQualifiedFolderName .= " - " . $publicStoreName[PR_DISPLAY_NAME]; |
| 503 | - } |
|
| 504 | - elseif ($destinationFolderProps[PR_MDB_PROVIDER] === ZARAFA_STORE_DELEGATE_GUID) { |
|
| 487 | + } elseif ($destinationFolderProps[PR_MDB_PROVIDER] === ZARAFA_STORE_DELEGATE_GUID) { |
|
| 505 | 488 | // Condition true if folder is belongs to delegate store. |
| 506 | 489 | $otherStore = $GLOBALS['operations']->getOtherStoreFromEntryid($this->destinationFolderId); |
| 507 | 490 | $sharedStoreOwnerName = mapi_getprops($otherStore, [PR_MAILBOX_OWNER_NAME]); |
@@ -511,14 +494,11 @@ discard block |
||
| 511 | 494 | $message = sprintf(_("Unable to import '%s' to '%s'. "), $filename, $fullyQualifiedFolderName); |
| 512 | 495 | if ($e->getCode() === MAPI_E_TABLE_EMPTY) { |
| 513 | 496 | $message .= _("There is no appointment found in this file."); |
| 514 | - } |
|
| 515 | - elseif ($e->getCode() === MAPI_E_CORRUPT_DATA) { |
|
| 497 | + } elseif ($e->getCode() === MAPI_E_CORRUPT_DATA) { |
|
| 516 | 498 | $message .= _("The file is corrupt."); |
| 517 | - } |
|
| 518 | - elseif ($e->getCode() === MAPI_E_INVALID_PARAMETER) { |
|
| 499 | + } elseif ($e->getCode() === MAPI_E_INVALID_PARAMETER) { |
|
| 519 | 500 | $message .= _("The file is invalid."); |
| 520 | - } |
|
| 521 | - else { |
|
| 501 | + } else { |
|
| 522 | 502 | $message = sprintf(_("Unable to import '%s'. "), $filename) . _("Please contact your system administrator if the problem persists."); |
| 523 | 503 | } |
| 524 | 504 | |
@@ -570,8 +550,7 @@ discard block |
||
| 570 | 550 | // but if it doesn't exist, we use the old function 'mapi_icaltomapi' for single ics file. |
| 571 | 551 | if (function_exists('mapi_icaltomapi2')) { |
| 572 | 552 | $events = mapi_icaltomapi2($addrBook, $this->destinationFolder, $attachmentStream); |
| 573 | - } |
|
| 574 | - elseif ($_POST['is_single_import']) { |
|
| 553 | + } elseif ($_POST['is_single_import']) { |
|
| 575 | 554 | $newMessage = mapi_folder_createmessage($this->destinationFolder); |
| 576 | 555 | $store = $GLOBALS["mapisession"]->getDefaultMessageStore(); |
| 577 | 556 | $ok = mapi_icaltomapi($GLOBALS['mapisession']->getSession(), $store, $addrBook, $newMessage, $attachmentStream, false); |
@@ -579,8 +558,7 @@ discard block |
||
| 579 | 558 | if ($ok !== false) { |
| 580 | 559 | array_push($events, $newMessage); |
| 581 | 560 | } |
| 582 | - } |
|
| 583 | - else { |
|
| 561 | + } else { |
|
| 584 | 562 | // Throw error related to multiple ics as the function is not available for importing multiple ics file. |
| 585 | 563 | throw new ZarafaException(_("grommunio Web does not support importing multiple ICS with this version.")); |
| 586 | 564 | } |
@@ -630,8 +608,7 @@ discard block |
||
| 630 | 608 | |
| 631 | 609 | try { |
| 632 | 610 | $destinationFolder = mapi_msgstore_openentry($this->store, hex2bin($this->destinationFolderId)); |
| 633 | - } |
|
| 634 | - catch (Exception $e) { |
|
| 611 | + } catch (Exception $e) { |
|
| 635 | 612 | // Try to find the folder from shared stores in case if it is not found in current user's store |
| 636 | 613 | $destinationFolder = mapi_msgstore_openentry($GLOBALS['operations']->getOtherStoreFromEntryid($this->destinationFolderId), hex2bin($this->destinationFolderId)); |
| 637 | 614 | } |
@@ -654,8 +631,7 @@ discard block |
||
| 654 | 631 | |
| 655 | 632 | // Delete the file instance and unregister the file |
| 656 | 633 | $this->attachment_state->deleteUploadedAttachmentFile($_REQUEST['dialog_attachments'], $num, $attachID); |
| 657 | - } |
|
| 658 | - else { |
|
| 634 | + } else { |
|
| 659 | 635 | // Set the correct array structure |
| 660 | 636 | $this->attachment_state->addDeletedAttachment($_REQUEST['dialog_attachments'], $num); |
| 661 | 637 | } |
@@ -735,8 +711,7 @@ discard block |
||
| 735 | 711 | 'type' => mime_content_type($tmpname), |
| 736 | 712 | 'sourcetype' => 'default', |
| 737 | 713 | ]); |
| 738 | - } |
|
| 739 | - else { |
|
| 714 | + } else { |
|
| 740 | 715 | // Check if no files are uploaded with this attachmentid |
| 741 | 716 | $this->attachment_state->clearAttachmentFiles($_GET['attachment_id']); |
| 742 | 717 | } |
@@ -857,15 +832,12 @@ discard block |
||
| 857 | 832 | if (isset($_FILES['attachments']) && is_array($_FILES['attachments'])) { |
| 858 | 833 | // import given files into respective webapp folder |
| 859 | 834 | $this->processFiles(); |
| 860 | - } |
|
| 861 | - elseif (isset($_POST['deleteattachment'])) { |
|
| 835 | + } elseif (isset($_POST['deleteattachment'])) { |
|
| 862 | 836 | $this->deleteUploadedFiles(); |
| 863 | - } |
|
| 864 | - elseif (isset($_POST['entryid'])) { // Check for adding of embedded attachments |
|
| 837 | + } elseif (isset($_POST['entryid'])) { // Check for adding of embedded attachments |
|
| 865 | 838 | $this->addingEmbeddedAttachments(); |
| 866 | 839 | } |
| 867 | - } |
|
| 868 | - elseif ($_GET && isset($_GET['attachment_id'])) { // this is to upload the file to server when the doc is send via OOo |
|
| 840 | + } elseif ($_GET && isset($_GET['attachment_id'])) { // this is to upload the file to server when the doc is send via OOo |
|
| 869 | 841 | $this->uploadWhenWendViaOOO(); |
| 870 | 842 | } |
| 871 | 843 | |
@@ -882,10 +854,8 @@ discard block |
||
| 882 | 854 | |
| 883 | 855 | // upload files |
| 884 | 856 | $uploadInstance->upload(); |
| 885 | -} |
|
| 886 | -catch (ZarafaException $e) { |
|
| 857 | +} catch (ZarafaException $e) { |
|
| 887 | 858 | $uploadInstance->handleUploadException($e, $e->getTitle()); |
| 888 | -} |
|
| 889 | -catch (Exception $e) { |
|
| 859 | +} catch (Exception $e) { |
|
| 890 | 860 | $uploadInstance->handleUploadException($e); |
| 891 | 861 | } |