@@ -18,7 +18,7 @@ |
||
| 18 | 18 | * |
| 19 | 19 | * @return Connection $connector |
| 20 | 20 | */ |
| 21 | -function CreateConnection($keystorePath='../../keystore.php', $useTlsOptions=true) |
|
| 21 | +function CreateConnection($keystorePath = '../../keystore.php', $useTlsOptions = true) |
|
| 22 | 22 | { |
| 23 | 23 | $publicKeyStore = CreatePublicKeyStore($keystorePath); |
| 24 | 24 | $settings = CreateConnectionSettings($publicKeyStore, $useTlsOptions); |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | * @param string optional suffix (usually 'private:' or 'public:') (default: '') |
| 13 | 13 | * @return bool whether the key is valid (true) or not (false) |
| 14 | 14 | */ |
| 15 | -function KeyCheck($publicKey, $suffix='') |
|
| 15 | +function KeyCheck($publicKey, $suffix = '') |
|
| 16 | 16 | { |
| 17 | 17 | // RegExp: https://regex101.com/r/sU5tC8/1 |
| 18 | - return preg_match('/^(' . $suffix . ')?[[:alnum:]]{64}$/', $publicKey); |
|
| 18 | + return preg_match('/^('.$suffix.')?[[:alnum:]]{64}$/', $publicKey); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | function FetchPublicKey($connector, $threemaId) |
| 34 | 34 | { |
| 35 | 35 | $result = $connector->fetchPublicKey($threemaId); |
| 36 | - if($result->isSuccess()) { |
|
| 36 | + if ($result->isSuccess()) { |
|
| 37 | 37 | return $result->getPublicKey(); |
| 38 | 38 | } |
| 39 | 39 | else { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | //get params |
| 45 | 45 | $threemaId = null; |
| 46 | 46 | if (ReturnGetPost('threemaid') && |
| 47 | - preg_match('/' . REGEXP_THREEMAID_ANY . '/', ReturnGetPost('threemaid')) |
|
| 47 | + preg_match('/'.REGEXP_THREEMAID_ANY.'/', ReturnGetPost('threemaid')) |
|
| 48 | 48 | ) { |
| 49 | 49 | $threemaId = htmlentities(ReturnGetPost('threemaid')); |
| 50 | 50 | } |
@@ -35,8 +35,7 @@ discard block |
||
| 35 | 35 | $result = $connector->fetchPublicKey($threemaId); |
| 36 | 36 | if($result->isSuccess()) { |
| 37 | 37 | return $result->getPublicKey(); |
| 38 | - } |
|
| 39 | - else { |
|
| 38 | + } else { |
|
| 40 | 39 | throw new Exception($result->getErrorMessage()); |
| 41 | 40 | } |
| 42 | 41 | } |
@@ -57,8 +56,7 @@ discard block |
||
| 57 | 56 | try { |
| 58 | 57 | $publicKey = FetchPublicKey($connector, $threemaId); |
| 59 | 58 | echo $publicKey; |
| 60 | - } |
|
| 61 | - catch (Exception $e) { |
|
| 59 | + } catch (Exception $e) { |
|
| 62 | 60 | http_response_code(500); |
| 63 | 61 | echo $e->getMessage(); |
| 64 | 62 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $fileConnCredentErr .= ' Not all required constants are defined.'; |
| 60 | 60 | } else { |
| 61 | 61 | if (MSGAPI_GATEWAY_THREEMA_ID == '' || |
| 62 | - !preg_match('/' . REGEXP_THREEMAID_GATEWAY . '/', MSGAPI_GATEWAY_THREEMA_ID) |
|
| 62 | + !preg_match('/'.REGEXP_THREEMAID_GATEWAY.'/', MSGAPI_GATEWAY_THREEMA_ID) |
|
| 63 | 63 | ) { |
| 64 | 64 | $fileConnCredentErr .= ' \'MSGAPI_GATEWAY_THREEMA_ID\' is invalid.'; |
| 65 | 65 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | if (MSGAPI_DEFAULTRECEIVER <> '' && |
| 79 | - !preg_match('/' . REGEXP_THREEMAID_ANY . '/', MSGAPI_DEFAULTRECEIVER) |
|
| 79 | + !preg_match('/'.REGEXP_THREEMAID_ANY.'/', MSGAPI_DEFAULTRECEIVER) |
|
| 80 | 80 | ) { |
| 81 | 81 | $fileConnCredentErr .= ' \'MSGAPI_DEFAULTRECEIVER\' is invalid.'; |
| 82 | 82 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | <!-- files already exist - no need to show instructions --> |
| 135 | 135 | <?php else: ?> |
| 136 | 136 | <p> |
| 137 | - Before you can use this test you have to get credentials at <a href="https://gateway.threema.ch" title="Threema Gateway">gateway.threema.ch</a> and <a href="https://github.com/rugk/threema-msgapi-sdk-php/wiki/How-to-generate-a-new-key-pair-and-send-a-message">create a key pair</a>. After you did so, you have to open <code><?php echo FILENAME_CONNCRED . FILEEXT_EXAMPLE ?></code> and <code><?php echo FILENAME_PRIVKEY . FILEEXT_EXAMPLE ?></code> and add your credentials and private key. Save them without the <code><?php echo FILEEXT_EXAMPLE ?></code> file extension afterwards. |
|
| 137 | + Before you can use this test you have to get credentials at <a href="https://gateway.threema.ch" title="Threema Gateway">gateway.threema.ch</a> and <a href="https://github.com/rugk/threema-msgapi-sdk-php/wiki/How-to-generate-a-new-key-pair-and-send-a-message">create a key pair</a>. After you did so, you have to open <code><?php echo FILENAME_CONNCRED.FILEEXT_EXAMPLE ?></code> and <code><?php echo FILENAME_PRIVKEY.FILEEXT_EXAMPLE ?></code> and add your credentials and private key. Save them without the <code><?php echo FILEEXT_EXAMPLE ?></code> file extension afterwards. |
|
| 138 | 138 | By default these files are excluded from git pulls so you will not accidentally publish these sensitive files. |
| 139 | 139 | </p> |
| 140 | 140 | <?php endif ?> |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | </fieldset> |
| 222 | 222 | <fieldset id="field_method"> |
| 223 | 223 | <legend>Method</legend> |
| 224 | - <input id="SrvMethodGet" name="servermethod" type="radio" <?php if ($_SERVER['REQUEST_METHOD'] == 'GET') {echo 'checked="checked"';}?> value="get"> |
|
| 224 | + <input id="SrvMethodGet" name="servermethod" type="radio" <?php if ($_SERVER['REQUEST_METHOD'] == 'GET') {echo 'checked="checked"'; }?> value="get"> |
|
| 225 | 225 | <label for="SrvMethodGet">GET</label> |
| 226 | - <input id="SrvMethodPost" name="servermethod" type="radio" <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') {echo 'checked="checked"';}?> value="post"> |
|
| 226 | + <input id="SrvMethodPost" name="servermethod" type="radio" <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') {echo 'checked="checked"'; }?> value="post"> |
|
| 227 | 227 | <label for="SrvMethodPost">POST</label> |
| 228 | 228 | <br /> |
| 229 | 229 | <input id="ButtonExternalScript" name="isExternal" type="checkbox"> |
@@ -132,7 +132,8 @@ discard block |
||
| 132 | 132 | <h2 id="prerequisites">Prerequisites</h2> |
| 133 | 133 | <?php if ($fileConnCredentErr == '' && $fileChkPrivateKeyErr == ''): ?> |
| 134 | 134 | <!-- files already exist - no need to show instructions --> |
| 135 | - <?php else: ?> |
|
| 135 | + <?php else { |
|
| 136 | + : ?> |
|
| 136 | 137 | <p> |
| 137 | 138 | Before you can use this test you have to get credentials at <a href="https://gateway.threema.ch" title="Threema Gateway">gateway.threema.ch</a> and <a href="https://github.com/rugk/threema-msgapi-sdk-php/wiki/How-to-generate-a-new-key-pair-and-send-a-message">create a key pair</a>. After you did so, you have to open <code><?php echo FILENAME_CONNCRED . FILEEXT_EXAMPLE ?></code> and <code><?php echo FILENAME_PRIVKEY . FILEEXT_EXAMPLE ?></code> and add your credentials and private key. Save them without the <code><?php echo FILEEXT_EXAMPLE ?></code> file extension afterwards. |
| 138 | 139 | By default these files are excluded from git pulls so you will not accidentally publish these sensitive files. |
@@ -192,7 +193,9 @@ discard block |
||
| 192 | 193 | You did not prepared your setup correctly to use the test. Please follow the intructions above to setup your environment. |
| 193 | 194 | </div> |
| 194 | 195 | <?php else: ?> |
| 195 | - <form id="mainform" action="." method="<?php echo $_SERVER['REQUEST_METHOD']; ?>"> |
|
| 196 | + <form id="mainform" action="." method="<?php echo $_SERVER['REQUEST_METHOD']; |
|
| 197 | +} |
|
| 198 | +?>"> |
|
| 196 | 199 | <div class="formcontainer"> |
| 197 | 200 | <fieldset id="field_generalsettings"> |
| 198 | 201 | <legend>General settings</legend> |
@@ -39,10 +39,10 @@ |
||
| 39 | 39 | $result = $e2eHelper->sendTextMessage($receiverId, $message); |
| 40 | 40 | |
| 41 | 41 | //show result |
| 42 | - if(true === $result->isSuccess()) { |
|
| 43 | - echo 'Message ID: '.$result->getMessageId() . "\n"; |
|
| 42 | + if (true === $result->isSuccess()) { |
|
| 43 | + echo 'Message ID: '.$result->getMessageId()."\n"; |
|
| 44 | 44 | } else { |
| 45 | - echo 'Error: '.$result->getErrorMessage() . "\n"; |
|
| 45 | + echo 'Error: '.$result->getErrorMessage()."\n"; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | //get params |
| 52 | 52 | if (ReturnGetPost('recieverid') && |
| 53 | - preg_match('/' . REGEXP_THREEMAID_ANY . '/', ReturnGetPost('recieverid')) |
|
| 53 | + preg_match('/'.REGEXP_THREEMAID_ANY.'/', ReturnGetPost('recieverid')) |
|
| 54 | 54 | ) { |
| 55 | 55 | $threemaId = htmlentities(ReturnGetPost('recieverid')); |
| 56 | 56 | $message = ReturnGetPost('message'); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | //Show direct output if the file is called directly |
| 78 | 78 | if (!$isIncluded) { |
| 79 | 79 | if ($errorMessage == null) { |
| 80 | - echo 'Message ID: ' . $messageId; |
|
| 80 | + echo 'Message ID: '.$messageId; |
|
| 81 | 81 | } else { |
| 82 | 82 | echo $errorMessage; |
| 83 | 83 | } |