@@ -95,7 +95,7 @@ |
||
95 | 95 | 'notifier' => [ |
96 | 96 | 'info' => [ |
97 | 97 | 'files' => [ |
98 | - 'value' => "dropdown", // static notifier |
|
98 | + 'value' => "dropdown", // static notifier |
|
99 | 99 | ], |
100 | 100 | ], |
101 | 101 | ], |
@@ -45,37 +45,37 @@ |
||
45 | 45 | |
46 | 46 | case 'server.index.load.custom': |
47 | 47 | switch ($data['name']) { |
48 | - case 'files_get_recipients': |
|
49 | - RecipientHandler::doGetRecipients(); |
|
50 | - break; |
|
48 | + case 'files_get_recipients': |
|
49 | + RecipientHandler::doGetRecipients(); |
|
50 | + break; |
|
51 | 51 | |
52 | - case 'download_file': |
|
53 | - DownloadHandler::doDownload(); |
|
54 | - break; |
|
52 | + case 'download_file': |
|
53 | + DownloadHandler::doDownload(); |
|
54 | + break; |
|
55 | 55 | |
56 | - case 'upload_file': |
|
57 | - UploadHandler::doUpload(); |
|
58 | - break; |
|
56 | + case 'upload_file': |
|
57 | + UploadHandler::doUpload(); |
|
58 | + break; |
|
59 | 59 | |
60 | - case 'form': |
|
61 | - if (isset($_GET['backend'])) { |
|
62 | - $backend = urldecode($_GET["backend"]); |
|
63 | - } |
|
64 | - else { |
|
65 | - $backend = ''; |
|
66 | - } |
|
67 | - $backendstore = Files\Backend\BackendStore::getInstance(); |
|
60 | + case 'form': |
|
61 | + if (isset($_GET['backend'])) { |
|
62 | + $backend = urldecode($_GET["backend"]); |
|
63 | + } |
|
64 | + else { |
|
65 | + $backend = ''; |
|
66 | + } |
|
67 | + $backendstore = Files\Backend\BackendStore::getInstance(); |
|
68 | 68 | |
69 | - if ($backendstore->backendExists($backend)) { |
|
70 | - $backendInstance = $backendstore->getInstanceOfBackend($backend); |
|
71 | - $formdata = $backendInstance->getFormConfig(); |
|
69 | + if ($backendstore->backendExists($backend)) { |
|
70 | + $backendInstance = $backendstore->getInstanceOfBackend($backend); |
|
71 | + $formdata = $backendInstance->getFormConfig(); |
|
72 | 72 | |
73 | - exit($formdata); |
|
74 | - } |
|
73 | + exit($formdata); |
|
74 | + } |
|
75 | 75 | |
76 | - exit("Specified backend does not exist!"); |
|
76 | + exit("Specified backend does not exist!"); |
|
77 | 77 | |
78 | - break; |
|
78 | + break; |
|
79 | 79 | } |
80 | 80 | break; |
81 | 81 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * Search the backend folder for backends and register them. |
61 | 61 | */ |
62 | 62 | public function initialize() { |
63 | - $list = []; // this hold our plugin folders |
|
63 | + $list = []; // this hold our plugin folders |
|
64 | 64 | $workdir = __DIR__ . self::BACKEND_DIR; |
65 | 65 | |
66 | 66 | // Populate the list of directories to check against |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Search the backend folder for external backends and register them. |
88 | 88 | */ |
89 | 89 | public function initializeExternal() { |
90 | - $list = []; // this hold our plugin folders |
|
90 | + $list = []; // this hold our plugin folders |
|
91 | 91 | $workdir = $this->EXTERNAL_BACKEND_DIR; |
92 | 92 | |
93 | 93 | // Populate the list of directories to check against |
@@ -191,7 +191,7 @@ |
||
191 | 191 | "fields" => $this->formFields, |
192 | 192 | "formConfig" => $this->formConfig, |
193 | 193 | ], |
194 | - "data" => [ // here we can specify the default values. |
|
194 | + "data" => [// here we can specify the default values. |
|
195 | 195 | "server_address" => "files.demo.com", |
196 | 196 | "server_port" => "80", |
197 | 197 | "server_path" => "/remote.php/webdav", |
@@ -136,7 +136,7 @@ |
||
136 | 136 | "fields" => $this->formFields, |
137 | 137 | "formConfig" => $this->formConfig, |
138 | 138 | ], |
139 | - "data" => [ // here we can specify the default values. |
|
139 | + "data" => [// here we can specify the default values. |
|
140 | 140 | "server_address" => $_SERVER['HTTP_HOST'], |
141 | 141 | "server_ssl" => true, |
142 | 142 | "server_port" => "443", |
@@ -445,7 +445,7 @@ |
||
445 | 445 | |
446 | 446 | public static function my_rsa_sha_encode($data, $key_id, $signagure_alg) { |
447 | 447 | $algos = [ |
448 | - 'sha1WithRSAEncryption' => ['alg' => 'sha1', 'oid' => '1.3.14.3.2.26'], |
|
448 | + 'sha1WithRSAEncryption' => ['alg' => 'sha1', 'oid' => '1.3.14.3.2.26'], |
|
449 | 449 | 'sha256WithRSAEncryption' => ['alg' => 'sha256', 'oid' => '2.16.840.1.101.3.4.2.1'], |
450 | 450 | 'sha384WithRSAEncryption' => ['alg' => 'sha384', 'oid' => '2.16.840.1.101.3.4.2.2'], |
451 | 451 | 'sha512WithRSAEncryption' => ['alg' => 'sha512', 'oid' => '2.16.840.1.101.3.4.2.3'], |
@@ -212,7 +212,7 @@ |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | protected function name($tag = null) { |
215 | - $this->beginsequence($tag); # seq of RDN |
|
215 | + $this->beginsequence($tag); # seq of RDN |
|
216 | 216 | $res = []; |
217 | 217 | while ($this->in()) { |
218 | 218 | $parts = []; |
@@ -454,7 +454,7 @@ |
||
454 | 454 | } |
455 | 455 | |
456 | 456 | if (!encryptionStoreExpirationSupport()) { |
457 | - withPHPSession(function () use ($encryptionStore) { |
|
457 | + withPHPSession(function() use ($encryptionStore) { |
|
458 | 458 | $encryptionStore->add('smime', ''); |
459 | 459 | }); |
460 | 460 | } |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | $messageClass = mapi_getprops($message, [PR_MESSAGE_CLASS]); |
164 | 164 | $messageClass = $messageClass[PR_MESSAGE_CLASS]; |
165 | 165 | if ($messageClass !== 'IPM.Note.SMIME' && |
166 | - $messageClass !== 'IPM.Note.SMIME.SignedEncrypt' && |
|
167 | - $messageClass !== 'IPM.Note.deferSMIME' && |
|
168 | - $messageClass !== 'IPM.Note.deferSMIME.SignedEncrypt') |
|
166 | + $messageClass !== 'IPM.Note.SMIME.SignedEncrypt' && |
|
167 | + $messageClass !== 'IPM.Note.deferSMIME' && |
|
168 | + $messageClass !== 'IPM.Note.deferSMIME.SignedEncrypt') |
|
169 | 169 | return; |
170 | 170 | |
171 | 171 | $recipients = $data['action']['props']['smime']; |
@@ -607,17 +607,17 @@ discard block |
||
607 | 607 | if (!isset($messageClass)) |
608 | 608 | return; |
609 | 609 | if (stripos($messageClass, 'IPM.Note.deferSMIME') === false && |
610 | - stripos($messageClass, 'IPM.Note.SMIME') === false) |
|
610 | + stripos($messageClass, 'IPM.Note.SMIME') === false) |
|
611 | 611 | return; |
612 | 612 | |
613 | 613 | // FIXME: for now return when we are going to sign but we don't have the passphrase set |
614 | 614 | // This should never happen sign |
615 | 615 | $encryptionStore = \EncryptionStore::getInstance(); |
616 | 616 | if (($messageClass === 'IPM.Note.deferSMIME.SignedEncrypt' || |
617 | - $messageClass === 'IPM.Note.deferSMIME.MultipartSigned' || |
|
618 | - $messageClass === 'IPM.Note.SMIME.SignedEncrypt' || |
|
619 | - $messageClass === 'IPM.Note.SMIME.MultipartSigned') && |
|
620 | - !$encryptionStore->get('smime')) |
|
617 | + $messageClass === 'IPM.Note.deferSMIME.MultipartSigned' || |
|
618 | + $messageClass === 'IPM.Note.SMIME.SignedEncrypt' || |
|
619 | + $messageClass === 'IPM.Note.SMIME.MultipartSigned') && |
|
620 | + !$encryptionStore->get('smime')) |
|
621 | 621 | return; |
622 | 622 | // NOTE: setting message class to IPM.Note, so that mapi_inetmapi_imtoinet converts the message to plain email |
623 | 623 | // and doesn't fail when handling the attachments. |
@@ -92,45 +92,45 @@ discard block |
||
92 | 92 | public function execute($eventID, &$data) { |
93 | 93 | switch ($eventID) { |
94 | 94 | // Register plugin |
95 | - case 'server.core.settings.init.before': |
|
96 | - $this->onBeforeSettingsInit($data); |
|
97 | - break; |
|
98 | - // Verify a signed or encrypted message when an email is opened |
|
99 | - case 'server.util.parse_smime.signed': |
|
100 | - $this->onSignedMessage($data); |
|
101 | - break; |
|
102 | - |
|
103 | - case 'server.util.parse_smime.encrypted': |
|
104 | - $this->onEncrypted($data); |
|
105 | - break; |
|
106 | - // Add S/MIME property, which is send to the client |
|
107 | - case 'server.module.itemmodule.open.after': |
|
108 | - $this->onAfterOpen($data); |
|
109 | - break; |
|
110 | - // Catch uploaded certificate |
|
111 | - case 'server.upload_attachment.upload': |
|
112 | - $this->onUploadCertificate($data); |
|
113 | - break; |
|
114 | - // Sign email before sending |
|
115 | - case 'server.core.operations.submitmessage': |
|
116 | - $this->onBeforeSend($data); |
|
117 | - break; |
|
118 | - // Verify that we have public certificates for all recipients |
|
119 | - case 'server.module.createmailitemmodule.beforesend': |
|
120 | - $this->onCertificateCheck($data); |
|
121 | - break; |
|
122 | - |
|
123 | - case 'server.index.load.custom': |
|
124 | - if ($data['name'] === 'smime_passphrase') { |
|
125 | - include 'templates/passphrase.tpl.php'; |
|
126 | - exit(); |
|
127 | - } |
|
128 | - if ($data['name'] === 'smime_passphrasecheck') { |
|
129 | - // No need to do anything, this is just used to trigger |
|
130 | - // the browser's autofill save password dialog. |
|
131 | - exit(); |
|
132 | - } |
|
133 | - break; |
|
95 | + case 'server.core.settings.init.before': |
|
96 | + $this->onBeforeSettingsInit($data); |
|
97 | + break; |
|
98 | + // Verify a signed or encrypted message when an email is opened |
|
99 | + case 'server.util.parse_smime.signed': |
|
100 | + $this->onSignedMessage($data); |
|
101 | + break; |
|
102 | + |
|
103 | + case 'server.util.parse_smime.encrypted': |
|
104 | + $this->onEncrypted($data); |
|
105 | + break; |
|
106 | + // Add S/MIME property, which is send to the client |
|
107 | + case 'server.module.itemmodule.open.after': |
|
108 | + $this->onAfterOpen($data); |
|
109 | + break; |
|
110 | + // Catch uploaded certificate |
|
111 | + case 'server.upload_attachment.upload': |
|
112 | + $this->onUploadCertificate($data); |
|
113 | + break; |
|
114 | + // Sign email before sending |
|
115 | + case 'server.core.operations.submitmessage': |
|
116 | + $this->onBeforeSend($data); |
|
117 | + break; |
|
118 | + // Verify that we have public certificates for all recipients |
|
119 | + case 'server.module.createmailitemmodule.beforesend': |
|
120 | + $this->onCertificateCheck($data); |
|
121 | + break; |
|
122 | + |
|
123 | + case 'server.index.load.custom': |
|
124 | + if ($data['name'] === 'smime_passphrase') { |
|
125 | + include 'templates/passphrase.tpl.php'; |
|
126 | + exit(); |
|
127 | + } |
|
128 | + if ($data['name'] === 'smime_passphrasecheck') { |
|
129 | + // No need to do anything, this is just used to trigger |
|
130 | + // the browser's autofill save password dialog. |
|
131 | + exit(); |
|
132 | + } |
|
133 | + break; |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -663,23 +663,23 @@ discard block |
||
663 | 663 | |
664 | 664 | // Sign then Encrypt email |
665 | 665 | switch ($messageClass) { |
666 | - case 'IPM.Note.deferSMIME.SignedEncrypt': |
|
667 | - case 'IPM.Note.SMIME.SignedEncrypt': |
|
668 | - $tmpFile = tempnam(sys_get_temp_dir(), true); |
|
669 | - $this->sign($tmpSendEmail, $tmpFile, $message, $signedAttach, $smimeProps); |
|
670 | - $this->encrypt($tmpFile, $tmpSendSmimeEmail, $message, $signedAttach, $smimeProps); |
|
671 | - unlink($tmpFile); |
|
672 | - break; |
|
673 | - |
|
674 | - case 'IPM.Note.deferSMIME.MultipartSigned': |
|
675 | - case 'IPM.Note.SMIME.MultipartSigned': |
|
676 | - $this->sign($tmpSendEmail, $tmpSendSmimeEmail, $message, $signedAttach, $smimeProps); |
|
677 | - break; |
|
678 | - |
|
679 | - case 'IPM.Note.deferSMIME': |
|
680 | - case 'IPM.Note.SMIME': |
|
681 | - $this->encrypt($tmpSendEmail, $tmpSendSmimeEmail, $message, $signedAttach, $smimeProps); |
|
682 | - break; |
|
666 | + case 'IPM.Note.deferSMIME.SignedEncrypt': |
|
667 | + case 'IPM.Note.SMIME.SignedEncrypt': |
|
668 | + $tmpFile = tempnam(sys_get_temp_dir(), true); |
|
669 | + $this->sign($tmpSendEmail, $tmpFile, $message, $signedAttach, $smimeProps); |
|
670 | + $this->encrypt($tmpFile, $tmpSendSmimeEmail, $message, $signedAttach, $smimeProps); |
|
671 | + unlink($tmpFile); |
|
672 | + break; |
|
673 | + |
|
674 | + case 'IPM.Note.deferSMIME.MultipartSigned': |
|
675 | + case 'IPM.Note.SMIME.MultipartSigned': |
|
676 | + $this->sign($tmpSendEmail, $tmpSendSmimeEmail, $message, $signedAttach, $smimeProps); |
|
677 | + break; |
|
678 | + |
|
679 | + case 'IPM.Note.deferSMIME': |
|
680 | + case 'IPM.Note.SMIME': |
|
681 | + $this->encrypt($tmpSendEmail, $tmpSendSmimeEmail, $message, $signedAttach, $smimeProps); |
|
682 | + break; |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | // Save the signed message as attachment of the send email |
@@ -167,8 +167,9 @@ discard block |
||
167 | 167 | if ($messageClass !== 'IPM.Note.SMIME' && |
168 | 168 | $messageClass !== 'IPM.Note.SMIME.SignedEncrypt' && |
169 | 169 | $messageClass !== 'IPM.Note.deferSMIME' && |
170 | - $messageClass !== 'IPM.Note.deferSMIME.SignedEncrypt') |
|
171 | - return; |
|
170 | + $messageClass !== 'IPM.Note.deferSMIME.SignedEncrypt') { |
|
171 | + return; |
|
172 | + } |
|
172 | 173 | |
173 | 174 | $recipients = $data['action']['props']['smime']; |
174 | 175 | $missingCerts = []; |
@@ -303,8 +304,9 @@ discard block |
||
303 | 304 | $importCert = file_get_contents($outcert); |
304 | 305 | $parsedImportCert = openssl_x509_parse($importCert); |
305 | 306 | $parsedUserCert = openssl_x509_parse($userCert); |
306 | - if (!$signed_ok || $openssl_error_code === OPENSSL_CA_VERIFY_FAIL) |
|
307 | - continue; |
|
307 | + if (!$signed_ok || $openssl_error_code === OPENSSL_CA_VERIFY_FAIL) { |
|
308 | + continue; |
|
309 | + } |
|
308 | 310 | |
309 | 311 | // CA Checks out |
310 | 312 | $caCerts = $this->extractCAs($tmpfname); |
@@ -549,8 +551,9 @@ discard block |
||
549 | 551 | * @param mixed $data |
550 | 552 | */ |
551 | 553 | public function onUploadCertificate($data) { |
552 | - if ($data['sourcetype'] !== 'certificate') |
|
553 | - return; |
|
554 | + if ($data['sourcetype'] !== 'certificate') { |
|
555 | + return; |
|
556 | + } |
|
554 | 557 | $passphrase = $_POST['passphrase']; |
555 | 558 | $saveCert = false; |
556 | 559 | $tmpname = $data['tmpname']; |
@@ -625,11 +628,13 @@ discard block |
||
625 | 628 | $props = mapi_getprops($message, [PR_MESSAGE_CLASS]); |
626 | 629 | $messageClass = $props[PR_MESSAGE_CLASS]; |
627 | 630 | |
628 | - if (!isset($messageClass)) |
|
629 | - return; |
|
631 | + if (!isset($messageClass)) { |
|
632 | + return; |
|
633 | + } |
|
630 | 634 | if (stripos($messageClass, 'IPM.Note.deferSMIME') === false && |
631 | - stripos($messageClass, 'IPM.Note.SMIME') === false) |
|
632 | - return; |
|
635 | + stripos($messageClass, 'IPM.Note.SMIME') === false) { |
|
636 | + return; |
|
637 | + } |
|
633 | 638 | |
634 | 639 | // FIXME: for now return when we are going to sign but we don't have the passphrase set |
635 | 640 | // This should never happen sign |
@@ -638,8 +643,9 @@ discard block |
||
638 | 643 | $messageClass === 'IPM.Note.deferSMIME.MultipartSigned' || |
639 | 644 | $messageClass === 'IPM.Note.SMIME.SignedEncrypt' || |
640 | 645 | $messageClass === 'IPM.Note.SMIME.MultipartSigned') && |
641 | - !$encryptionStore->get('smime')) |
|
642 | - return; |
|
646 | + !$encryptionStore->get('smime')) { |
|
647 | + return; |
|
648 | + } |
|
643 | 649 | // NOTE: setting message class to IPM.Note, so that mapi_inetmapi_imtoinet converts the message to plain email |
644 | 650 | // and doesn't fail when handling the attachments. |
645 | 651 | mapi_setprops($message, [PR_MESSAGE_CLASS => 'IPM.Note']); |
@@ -883,8 +889,9 @@ discard block |
||
883 | 889 | foreach ($certs as $cert) { |
884 | 890 | $pubkey = mapi_msgstore_openentry($this->getStore(), $cert[PR_ENTRYID]); |
885 | 891 | $certificate = ""; |
886 | - if ($pubkey == false) |
|
887 | - continue; |
|
892 | + if ($pubkey == false) { |
|
893 | + continue; |
|
894 | + } |
|
888 | 895 | // retrieve pkcs#11 certificate from body |
889 | 896 | $stream = mapi_openproperty($pubkey, PR_BODY, IID_IStream, 0, 0); |
890 | 897 | $stat = mapi_stream_stat($stream); |
@@ -1006,8 +1013,9 @@ discard block |
||
1006 | 1013 | */ |
1007 | 1014 | public function importCertificate($cert, $certData, $type = 'public', $force = false) { |
1008 | 1015 | $certEmail = getCertEmail($certData); |
1009 | - if ($this->pubcertExists($certEmail) && !$force && $type !== 'private') |
|
1010 | - return; |
|
1016 | + if ($this->pubcertExists($certEmail) && !$force && $type !== 'private') { |
|
1017 | + return; |
|
1018 | + } |
|
1011 | 1019 | $issued_by = ""; |
1012 | 1020 | foreach (array_keys($certData['issuer']) as $key) { |
1013 | 1021 | $issued_by .= $key . '=' . $certData['issuer'][$key] . "\n"; |
@@ -1131,8 +1139,9 @@ discard block |
||
1131 | 1139 | * @return array with properties |
1132 | 1140 | */ |
1133 | 1141 | public function getSenderAddress($mapiMessage) { |
1134 | - if (method_exists($GLOBALS['operations'], 'getSenderAddress')) |
|
1135 | - return $GLOBALS["operations"]->getSenderAddress($mapiMessage); |
|
1142 | + if (method_exists($GLOBALS['operations'], 'getSenderAddress')) { |
|
1143 | + return $GLOBALS["operations"]->getSenderAddress($mapiMessage); |
|
1144 | + } |
|
1136 | 1145 | |
1137 | 1146 | $messageProps = mapi_getprops($mapiMessage, [PR_SENT_REPRESENTING_ENTRYID, PR_SENDER_ENTRYID]); |
1138 | 1147 | $senderEntryID = isset($messageProps[PR_SENT_REPRESENTING_ENTRYID]) ? $messageProps[PR_SENT_REPRESENTING_ENTRYID] : $messageProps[PR_SENDER_ENTRYID]; |
@@ -122,8 +122,8 @@ |
||
122 | 122 | if (!empty($action["query"]) && !empty($recipient_history) && !empty($recipient_history['recipients'])) { |
123 | 123 | // Setup result array with match levels |
124 | 124 | $l_aResult = [ |
125 | - 0 => [], // Matches on whole string |
|
126 | - 1 => [], // Matches on part of string |
|
125 | + 0 => [], // Matches on whole string |
|
126 | + 1 => [], // Matches on part of string |
|
127 | 127 | ]; |
128 | 128 | |
129 | 129 | // Loop through all the recipients |
@@ -358,7 +358,7 @@ |
||
358 | 358 | |
359 | 359 | if ($themeProps['primary-color']) { |
360 | 360 | if (!$themeProps['primary-color:hover']) { |
361 | - list(, , $l) = Colors::rgb2hsl(Colors::colorString2Object($themeProps['primary-color'])); |
|
361 | + list(,, $l) = Colors::rgb2hsl(Colors::colorString2Object($themeProps['primary-color'])); |
|
362 | 362 | if ($l > 20) { |
363 | 363 | $themeProps['primary-color:hover'] = Colors::darker($themeProps['primary-color'], 10); |
364 | 364 | } |