Completed
Pull Request — master (#28)
by rugk
02:50
created
samples/web/include/Connection.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
  *
33 33
  * @param string $keystorePath Path public key store file (PHP)
34 34
  *
35
- * @return PhpFile public key store
35
+ * @return Threema\MsgApi\PublicKeyStores\PhpFile public key store
36 36
  */
37 37
 function CreatePublicKeyStore($keystorePath)
38 38
 {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author rugk
4
- * @copyright Copyright (c) 2015 rugk
5
- * @license MIT
6
- */
3
+	 * @author rugk
4
+	 * @copyright Copyright (c) 2015 rugk
5
+	 * @license MIT
6
+	 */
7 7
 
8 8
 use Threema\MsgApi\Connection;
9 9
 use Threema\MsgApi\ConnectionSettings;
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function CreateConnection($keystorePath='../../keystore.php', $useTlsOptions=true)
22 22
 {
23
-    $publicKeyStore = CreatePublicKeyStore($keystorePath);
24
-    $settings = CreateConnectionSettings($useTlsOptions);
25
-    $connector = InitiateConnection($settings, $publicKeyStore);
23
+	$publicKeyStore = CreatePublicKeyStore($keystorePath);
24
+	$settings = CreateConnectionSettings($useTlsOptions);
25
+	$connector = InitiateConnection($settings, $publicKeyStore);
26 26
 
27
-    return $connector;
27
+	return $connector;
28 28
 }
29 29
 
30 30
 /**
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function CreatePublicKeyStore($keystorePath)
38 38
 {
39
-    if (!file_exists($keystorePath)) {
40
-        if (!touch($keystorePath)) {
41
-            throw new Exception("PHP keystore could not be created.");
42
-        }
43
-    }
44
-    return new Threema\MsgApi\PublicKeyStores\PhpFile($keystorePath);
39
+	if (!file_exists($keystorePath)) {
40
+		if (!touch($keystorePath)) {
41
+			throw new Exception("PHP keystore could not be created.");
42
+		}
43
+	}
44
+	return new Threema\MsgApi\PublicKeyStores\PhpFile($keystorePath);
45 45
 }
46 46
 
47 47
 /**
@@ -53,27 +53,27 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function CreateConnectionSettings($useTlsOptions)
55 55
 {
56
-    if ($useTlsOptions == true) {
57
-        //create a connection with advanced options
58
-        $settings = new ConnectionSettings(
59
-            MSGAPI_GATEWAY_THREEMA_ID,
60
-            MSGAPI_GATEWAY_THREEMA_ID_SECRET,
61
-            null,
62
-            [
63
-                'forceHttps' => true,
64
-                'tlsVersion' => '1.2',
65
-                'tlsCipher' => 'ECDHE-RSA-AES128-GCM-SHA256'
66
-            ]
67
-        );
68
-    } else {
69
-        //create a connection with default options
70
-        $settings = new ConnectionSettings(
71
-            MSGAPI_GATEWAY_THREEMA_ID,
72
-            MSGAPI_GATEWAY_THREEMA_ID_SECRET
73
-        );
74
-    }
56
+	if ($useTlsOptions == true) {
57
+		//create a connection with advanced options
58
+		$settings = new ConnectionSettings(
59
+			MSGAPI_GATEWAY_THREEMA_ID,
60
+			MSGAPI_GATEWAY_THREEMA_ID_SECRET,
61
+			null,
62
+			[
63
+				'forceHttps' => true,
64
+				'tlsVersion' => '1.2',
65
+				'tlsCipher' => 'ECDHE-RSA-AES128-GCM-SHA256'
66
+			]
67
+		);
68
+	} else {
69
+		//create a connection with default options
70
+		$settings = new ConnectionSettings(
71
+			MSGAPI_GATEWAY_THREEMA_ID,
72
+			MSGAPI_GATEWAY_THREEMA_ID_SECRET
73
+		);
74
+	}
75 75
 
76
-    return $settings;
76
+	return $settings;
77 77
 }
78 78
 
79 79
 /**
@@ -86,5 +86,5 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function InitiateConnection($settings, $publicKeyStore)
88 88
 {
89
-    return new Connection($settings, $publicKeyStore);
89
+	return new Connection($settings, $publicKeyStore);
90 90
 }
Please login to merge, or discard this patch.
samples/web/SendTextMessage.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
  * @param string $threemaId The id whose public key should be fetched
35 35
  * @param string $message The message to send (max 3500 characters)
36 36
  *
37
- * @return string|Exception
37
+ * @return string
38 38
  */
39 39
 function SendMessage($connector, $threemaId, $message)
40 40
 {
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -38,22 +38,22 @@  discard block
 block discarded – undo
38 38
  */
39 39
 function SendMessage($connector, $threemaId, $message)
40 40
 {
41
-    $e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper(KeyHexToBin(MSGAPI_PRIVATE_KEY), $connector);
42
-    $result = $e2eHelper->sendTextMessage($threemaId, $message);
41
+	$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper(KeyHexToBin(MSGAPI_PRIVATE_KEY), $connector);
42
+	$result = $e2eHelper->sendTextMessage($threemaId, $message);
43 43
 
44
-    if (true === $result->isSuccess()) {
45
-        return $result->getMessageId();
46
-    } else {
47
-        throw new Exception($result->getErrorMessage());
48
-    }
44
+	if (true === $result->isSuccess()) {
45
+		return $result->getMessageId();
46
+	} else {
47
+		throw new Exception($result->getErrorMessage());
48
+	}
49 49
 }
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
-    $threemaId = htmlentities(ReturnGetPost('recieverid'));
56
-    $message = ReturnGetPost('message');
55
+	$threemaId = htmlentities(ReturnGetPost('recieverid'));
56
+	$message = ReturnGetPost('message');
57 57
 }
58 58
 
59 59
 //create connection
@@ -61,24 +61,24 @@  discard block
 block discarded – undo
61 61
 
62 62
 //Send message
63 63
 if ($threemaId != null && $message != null) {
64
-    if (!$isIncluded) {
65
-        header('Content-Type: text/plain');
66
-    }
67
-    $actionDone = true;
64
+	if (!$isIncluded) {
65
+		header('Content-Type: text/plain');
66
+	}
67
+	$actionDone = true;
68 68
 
69
-    try {
70
-        $messageId = SendMessage($connector, $threemaId, $message);
71
-    } catch (Exception $e) {
72
-        http_response_code(500);
73
-        $errorMessage = $e->getMessage();
74
-    }
69
+	try {
70
+		$messageId = SendMessage($connector, $threemaId, $message);
71
+	} catch (Exception $e) {
72
+		http_response_code(500);
73
+		$errorMessage = $e->getMessage();
74
+	}
75 75
 }
76 76
 
77 77
 //Show direct output if the file is called directly
78 78
 if (!$isIncluded) {
79
-    if ($errorMessage == null) {
80
-        echo 'Message ID: ' . $messageId;
81
-    } else {
82
-        echo $errorMessage;
83
-    }
79
+	if ($errorMessage == null) {
80
+		echo 'Message ID: ' . $messageId;
81
+	} else {
82
+		echo $errorMessage;
83
+	}
84 84
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
samples/web/include/GetPost.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author rugk
4
- * @copyright Copyright (c) 2015 rugk
5
- * @license MIT
6
- */
3
+	 * @author rugk
4
+	 * @copyright Copyright (c) 2015 rugk
5
+	 * @license MIT
6
+	 */
7 7
 
8 8
 /**
9 9
  * Returns the parameter from GET (preferred) or POST.
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function ReturnGetPost($name)
15 15
 {
16
-    if (isset($_GET[$name])) {
17
-        return $_GET[$name];
18
-    }
19
-    if (isset($_POST[$name])) {
20
-        return $_POST[$name];
21
-    }
16
+	if (isset($_GET[$name])) {
17
+		return $_GET[$name];
18
+	}
19
+	if (isset($_POST[$name])) {
20
+		return $_POST[$name];
21
+	}
22 22
 
23
-    return null;
23
+	return null;
24 24
 }
Please login to merge, or discard this patch.
samples/web/include/GlobalConstants.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author rugk
4
- * @copyright Copyright (c) 2015 rugk
5
- * @license MIT
6
- */
3
+	 * @author rugk
4
+	 * @copyright Copyright (c) 2015 rugk
5
+	 * @license MIT
6
+	 */
7 7
 
8 8
 /* CONSTANTS */
9 9
 const FILENAME_CONNCRED = 'ConnectionCredentials.php';
Please login to merge, or discard this patch.
samples/web/index.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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">
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -132,7 +132,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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>
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <!--
2 2
 <?php
3 3
 /**
4
- * @author rugk
5
- * @copyright Copyright (c) 2015 rugk
6
- * @license MIT
7
- */
4
+	 * @author rugk
5
+	 * @copyright Copyright (c) 2015 rugk
6
+	 * @license MIT
7
+	 */
8 8
 
9 9
 /* INCLUDES */
10 10
 require_once 'include/GlobalConstants.php';
@@ -18,87 +18,87 @@  discard block
 block discarded – undo
18 18
 /* SOME SMALL FUNCTIONS */
19 19
 function ShowDefaultReceiverId($addOptionsHtmlCode = false)
20 20
 {
21
-    $isShown = ReturnGetPost('threemaid') != null || ReturnGetPost('recieverid')
22
-    != null || MSGAPI_DEFAULTRECEIVER <> '';
23
-
24
-    // Show previous input if there is something
25
-    if ($isShown && $addOptionsHtmlCode) {
26
-        echo '<option value="';
27
-    }
28
-
29
-    if (ReturnGetPost('threemaid') != null) {
30
-        echo htmlentities(ReturnGetPost('threemaid'));
31
-    } elseif (ReturnGetPost('recieverid') != null) {
32
-        echo htmlentities(ReturnGetPost('recieverid'));
33
-    } elseif (MSGAPI_DEFAULTRECEIVER <> '') {
34
-        // use receiver in config
35
-        echo MSGAPI_DEFAULTRECEIVER;
36
-    }
37
-
38
-    if ($isShown && $addOptionsHtmlCode) {
39
-        echo '">';
40
-    }
21
+	$isShown = ReturnGetPost('threemaid') != null || ReturnGetPost('recieverid')
22
+	!= null || MSGAPI_DEFAULTRECEIVER <> '';
23
+
24
+	// Show previous input if there is something
25
+	if ($isShown && $addOptionsHtmlCode) {
26
+		echo '<option value="';
27
+	}
28
+
29
+	if (ReturnGetPost('threemaid') != null) {
30
+		echo htmlentities(ReturnGetPost('threemaid'));
31
+	} elseif (ReturnGetPost('recieverid') != null) {
32
+		echo htmlentities(ReturnGetPost('recieverid'));
33
+	} elseif (MSGAPI_DEFAULTRECEIVER <> '') {
34
+		// use receiver in config
35
+		echo MSGAPI_DEFAULTRECEIVER;
36
+	}
37
+
38
+	if ($isShown && $addOptionsHtmlCode) {
39
+		echo '">';
40
+	}
41 41
 }
42 42
 
43 43
 function ShowDefaultMessage()
44 44
 {
45
-    // Show previous input if there is something
46
-    if (ReturnGetPost('message') != null) {
47
-        echo htmlentities(ReturnGetPost('message'));
48
-    }
45
+	// Show previous input if there is something
46
+	if (ReturnGetPost('message') != null) {
47
+		echo htmlentities(ReturnGetPost('message'));
48
+	}
49 49
 }
50 50
 
51 51
 /* CHECK PREREQUISITES */
52 52
 $fileConnCredentErr = '';
53 53
 if (!file_exists(FILENAME_CONNCRED)) {
54
-    $fileConnCredentErr .= ' The file does not exist.';
54
+	$fileConnCredentErr .= ' The file does not exist.';
55 55
 } else {
56
-    require_once FILENAME_CONNCRED;
57
-    if (!defined('MSGAPI_GATEWAY_THREEMA_ID') ||
58
-        !defined('MSGAPI_GATEWAY_THREEMA_ID_SECRET')
59
-    ) {
60
-        $fileConnCredentErr .= ' Not all required constants are defined.';
61
-    } else {
62
-        if (MSGAPI_GATEWAY_THREEMA_ID == '' ||
63
-            !preg_match('/' . REGEXP_THREEMAID_GATEWAY . '/', MSGAPI_GATEWAY_THREEMA_ID)
64
-        ) {
65
-            $fileConnCredentErr .= ' \'MSGAPI_GATEWAY_THREEMA_ID\' is invalid.';
66
-        }
67
-
68
-        if (MSGAPI_GATEWAY_THREEMA_ID_SECRET == '' ||
69
-            !ctype_alnum(MSGAPI_GATEWAY_THREEMA_ID_SECRET)
70
-        ) {
71
-            $fileConnCredentErr .= ' \'MSGAPI_GATEWAY_THREEMA_ID_SECRET\' is invalid.';
72
-        }
73
-
74
-        // MSGAPI_DEFAULTRECEIVER is optional
75
-        if (!defined('MSGAPI_DEFAULTRECEIVER')) {
76
-            define('MSGAPI_DEFAULTRECEIVER', '');
77
-        }
78
-
79
-        if (MSGAPI_DEFAULTRECEIVER <> '' &&
80
-            !preg_match('/' . REGEXP_THREEMAID_ANY . '/', MSGAPI_DEFAULTRECEIVER)
81
-        ) {
82
-            $fileConnCredentErr .= ' \'MSGAPI_DEFAULTRECEIVER\' is invalid.';
83
-        }
84
-    }
56
+	require_once FILENAME_CONNCRED;
57
+	if (!defined('MSGAPI_GATEWAY_THREEMA_ID') ||
58
+		!defined('MSGAPI_GATEWAY_THREEMA_ID_SECRET')
59
+	) {
60
+		$fileConnCredentErr .= ' Not all required constants are defined.';
61
+	} else {
62
+		if (MSGAPI_GATEWAY_THREEMA_ID == '' ||
63
+			!preg_match('/' . REGEXP_THREEMAID_GATEWAY . '/', MSGAPI_GATEWAY_THREEMA_ID)
64
+		) {
65
+			$fileConnCredentErr .= ' \'MSGAPI_GATEWAY_THREEMA_ID\' is invalid.';
66
+		}
67
+
68
+		if (MSGAPI_GATEWAY_THREEMA_ID_SECRET == '' ||
69
+			!ctype_alnum(MSGAPI_GATEWAY_THREEMA_ID_SECRET)
70
+		) {
71
+			$fileConnCredentErr .= ' \'MSGAPI_GATEWAY_THREEMA_ID_SECRET\' is invalid.';
72
+		}
73
+
74
+		// MSGAPI_DEFAULTRECEIVER is optional
75
+		if (!defined('MSGAPI_DEFAULTRECEIVER')) {
76
+			define('MSGAPI_DEFAULTRECEIVER', '');
77
+		}
78
+
79
+		if (MSGAPI_DEFAULTRECEIVER <> '' &&
80
+			!preg_match('/' . REGEXP_THREEMAID_ANY . '/', MSGAPI_DEFAULTRECEIVER)
81
+		) {
82
+			$fileConnCredentErr .= ' \'MSGAPI_DEFAULTRECEIVER\' is invalid.';
83
+		}
84
+	}
85 85
 }
86 86
 
87 87
 
88 88
 $fileChkPrivateKeyErr = '';
89 89
 if (!file_exists(FILENAME_PRIVKEY)) {
90
-    $fileChkPrivateKeyErr .= ' The file does not exist.';
90
+	$fileChkPrivateKeyErr .= ' The file does not exist.';
91 91
 } else {
92
-    require_once FILENAME_PRIVKEY;
93
-    if (!defined('MSGAPI_PRIVATE_KEY')) {
94
-        $fileChkPrivateKeyErr .= ' Not all constants are defined.';
95
-    } else {
96
-        if (MSGAPI_PRIVATE_KEY == '' ||
97
-            !KeyCheck(MSGAPI_PRIVATE_KEY, 'private:')
98
-        ) {
99
-            $fileChkPrivateKeyErr .= ' \'MSGAPI_PRIVATE_KEY\' is invalid.';
100
-        }
101
-    }
92
+	require_once FILENAME_PRIVKEY;
93
+	if (!defined('MSGAPI_PRIVATE_KEY')) {
94
+		$fileChkPrivateKeyErr .= ' Not all constants are defined.';
95
+	} else {
96
+		if (MSGAPI_PRIVATE_KEY == '' ||
97
+			!KeyCheck(MSGAPI_PRIVATE_KEY, 'private:')
98
+		) {
99
+			$fileChkPrivateKeyErr .= ' \'MSGAPI_PRIVATE_KEY\' is invalid.';
100
+		}
101
+	}
102 102
 }
103 103
 ?>
104 104
 -->
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
     </head>
113 113
     <body>
114 114
         <?php
115
-        // only shows content when it is not parsed by a PHP interpreter
116
-        if (false):
117
-        ?>
115
+		// only shows content when it is not parsed by a PHP interpreter
116
+		if (false):
117
+		?>
118 118
         <!-- PHP parsing error message -->
119 119
         <div class="warning">
120 120
             You are viewing this file within a browser. However you do need to call this file
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
             PHP support and access the file like this: <code>http://127.0.0.1/threema-msgapi-sdk-php/samples/web/</code>.
123 123
         </div>
124 124
         <?php
125
-        endif
126
-        ?>
125
+		endif
126
+		?>
127 127
 
128 128
         <h1 id="devui">Development UI - MSGAPI-PHP-SDK - Threema Gateway</h1>
129 129
         <p>
Please login to merge, or discard this patch.
samples/web/FetchPublicKey.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author rugk
4
- * @copyright Copyright (c) 2015 rugk
5
- * @license MIT
6
- */
3
+	 * @author rugk
4
+	 * @copyright Copyright (c) 2015 rugk
5
+	 * @license MIT
6
+	 */
7 7
 
8 8
 header('Content-Type: text/plain');
9 9
 
@@ -32,20 +32,20 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function FetchPublicKey($connector, $threemaId)
34 34
 {
35
-    $result = $connector->fetchPublicKey($threemaId);
36
-    if ($result->isSuccess()) {
37
-    	return $result->getPublicKey();
38
-    } else {
39
-    	throw new Exception($result->getErrorMessage());
40
-    }
35
+	$result = $connector->fetchPublicKey($threemaId);
36
+	if ($result->isSuccess()) {
37
+		return $result->getPublicKey();
38
+	} else {
39
+		throw new Exception($result->getErrorMessage());
40
+	}
41 41
 }
42 42
 
43 43
 //get params
44 44
 $threemaId = null;
45 45
 if (ReturnGetPost('threemaid') &&
46
-    preg_match('/' . REGEXP_THREEMAID_ANY . '/', ReturnGetPost('threemaid'))
46
+	preg_match('/' . REGEXP_THREEMAID_ANY . '/', ReturnGetPost('threemaid'))
47 47
 ) {
48
-    $threemaId = htmlentities(ReturnGetPost('threemaid'));
48
+	$threemaId = htmlentities(ReturnGetPost('threemaid'));
49 49
 }
50 50
 
51 51
 //create connection
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 
54 54
 //Fetch public key and return a 500 error in case of a failure
55 55
 if ($threemaId != null) {
56
-    try {
57
-        $publicKey = FetchPublicKey($connector, $threemaId);
58
-        echo $publicKey;
59
-    } catch (Exception $e) {
60
-        http_response_code(500);
61
-        echo $e->getMessage();
62
-    }
56
+	try {
57
+		$publicKey = FetchPublicKey($connector, $threemaId);
58
+		echo $publicKey;
59
+	} catch (Exception $e) {
60
+		http_response_code(500);
61
+		echo $e->getMessage();
62
+	}
63 63
 } else {
64
-    http_response_code(500);
65
-    echo 'Invalid Threema ID';
64
+	http_response_code(500);
65
+	echo 'Invalid Threema ID';
66 66
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 //get params
44 44
 $threemaId = null;
45 45
 if (ReturnGetPost('threemaid') &&
46
-    preg_match('/' . REGEXP_THREEMAID_ANY . '/', ReturnGetPost('threemaid'))
46
+    preg_match('/'.REGEXP_THREEMAID_ANY.'/', ReturnGetPost('threemaid'))
47 47
 ) {
48 48
     $threemaId = htmlentities(ReturnGetPost('threemaid'));
49 49
 }
Please login to merge, or discard this patch.
samples/web/SendE2EText.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author rugk
4
- * @copyright Copyright (c) 2015 rugk
5
- * @license MIT
6
- */
3
+	 * @author rugk
4
+	 * @copyright Copyright (c) 2015 rugk
5
+	 * @license MIT
6
+	 */
7 7
 
8 8
 header('Content-Type: text/plain');
9 9
 
@@ -31,19 +31,19 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function SendText($connector, $receiverId, $message)
33 33
 {
34
-    //get private key
35
-    $privateKey = KeyHexToBin(MSGAPI_PRIVATE_KEY);
36
-
37
-    //send message
38
-    $e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($privateKey, $connector);
39
-    $result = $e2eHelper->sendTextMessage($receiverId, $message);
40
-
41
-    //show result
42
-    if (true === $result->isSuccess()) {
43
-    	echo 'Message ID: '.$result->getMessageId() . "\n";
44
-    } else {
45
-    	echo 'Error: '.$result->getErrorMessage() . "\n";
46
-    }
34
+	//get private key
35
+	$privateKey = KeyHexToBin(MSGAPI_PRIVATE_KEY);
36
+
37
+	//send message
38
+	$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($privateKey, $connector);
39
+	$result = $e2eHelper->sendTextMessage($receiverId, $message);
40
+
41
+	//show result
42
+	if (true === $result->isSuccess()) {
43
+		echo 'Message ID: '.$result->getMessageId() . "\n";
44
+	} else {
45
+		echo 'Error: '.$result->getErrorMessage() . "\n";
46
+	}
47 47
 
48 48
 }
49 49
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@
 block discarded – undo
40 40
 
41 41
     //show result
42 42
     if (true === $result->isSuccess()) {
43
-    	echo 'Message ID: '.$result->getMessageId() . "\n";
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
 }
Please login to merge, or discard this patch.
samples/web/include/PublicKey.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function KeyCheck($publicKey, $suffix = '')
16 16
 {
17
-    // RegExp: https://regex101.com/r/sU5tC8/1
18
-    return preg_match('/^(' . $suffix . ')?[[:alnum:]]{64}$/', $publicKey);
17
+	// RegExp: https://regex101.com/r/sU5tC8/1
18
+	return preg_match('/^(' . $suffix . ')?[[:alnum:]]{64}$/', $publicKey);
19 19
 }
20 20
 
21 21
 /**
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function KeyGetUserDisplay($publicKey)
34 34
 {
35
-    //force key to be binary
36
-    if (ctype_alnum($publicKey)) {
37
-        $publicKey = KeyHexToBin($publicKey);
38
-    }
35
+	//force key to be binary
36
+	if (ctype_alnum($publicKey)) {
37
+		$publicKey = KeyHexToBin($publicKey);
38
+	}
39 39
 
40
-    //create short hash
41
-    $shortHash = substr(hash('sha256', $publicKey, 0, 32));
42
-    return $shortHash;
40
+	//create short hash
41
+	$shortHash = substr(hash('sha256', $publicKey, 0, 32));
42
+	return $shortHash;
43 43
 }
44 44
 
45 45
 /**
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function KeyHexToBin($keyHex)
53 53
 {
54
-    //delete prefix
55
-    $keyTypeCheck = substr($keyHex, 0, 8);
56
-    if ($keyTypeCheck == 'private:' || $keyTypeCheck == 'public:') {
57
-        $keyHex = substr($keyHex, 8);
58
-    }
54
+	//delete prefix
55
+	$keyTypeCheck = substr($keyHex, 0, 8);
56
+	if ($keyTypeCheck == 'private:' || $keyTypeCheck == 'public:') {
57
+		$keyHex = substr($keyHex, 8);
58
+	}
59 59
 
60
-    //convert key
61
-    $keyBin = hex2bin($keyHex);
62
-    return $keyBin;
60
+	//convert key
61
+	$keyBin = hex2bin($keyHex);
62
+	return $keyBin;
63 63
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 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
 /**
Please login to merge, or discard this patch.