Skip to content

Commit 6aa4d12

Browse files
committed
1.0.8 Better json decoding, ignoring chr(13)
1 parent f02a840 commit 6aa4d12

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SMSGateway Change Log
22

3-
## Version 1.0.7 (2023-03-30)
3+
## Version 1.0.8 (2023-03-30)
44

55
### Fixed bugs
66
* Better json decoding, ignoring chr(13)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.6
1+
1.0.8

examples/gateway.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* PHP 5.3.0 or higher is supported.
88
*
99
* @author Andre Liechti (SysCo systemes de communication sa) <info@multiotp.net>
10-
* @version 1.1.0
11-
* @date 2023-03-21
10+
* @version 1.1.1
11+
* @date 2023-03-30
1212
* @since 2022-09-10
1313
* @copyright (c) 2022-2023 SysCo systemes de communication sa
1414
* @copyright GNU Lesser General Public License

src/SMSGateway.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* PHP 5.3.0 or higher is supported.
2020
*
2121
* @author Andre Liechti (SysCo systemes de communication sa) <info@multiotp.net>
22-
* @version 1.0.7
22+
* @version 1.0.8
2323
* @date 2023-03-30
2424
* @since 2022-09-10
2525
* @copyright (c) 2022-2023 SysCo systemes de communication sa
@@ -421,7 +421,7 @@ public function handleMessages(
421421
$post_data
422422
) {
423423
$result_array = array();
424-
$extract_data = json_decode($post_data, true);
424+
$extract_data = json_decode(str_replace(chr(13), "", $post_data), true);
425425
if (null != $extract_data) {
426426
if (isset($extract_data["messages"])) {
427427
foreach($extract_data["messages"] as $message) {
@@ -457,15 +457,15 @@ public function handleUpdates(
457457
$post_data
458458
) {
459459
$result_array = array();
460-
$extract_data = json_decode($post_data, true);
460+
$extract_data = json_decode(str_replace(chr(13), "", $post_data), true);
461461
if (null != $extract_data) {
462462
if (isset($extract_data["updates"])) {
463463
foreach($extract_data["updates"] as $update) {
464464
if (isset($update["id"])) {
465465
if (isset($update["status"])) {
466466
$message_array = glob($this->getDevicePathSend() . $update["id"] . ".*");
467467
if (1 == count($message_array)) {
468-
$extract_data = json_decode(file_get_contents($message_array[0]), true);
468+
$extract_data = json_decode(str_replace(chr(13), "", file_get_contents($message_array[0])), true);
469469
$content = "";
470470
$to = "";
471471
if (null != $extract_data) {
@@ -481,6 +481,7 @@ public function handleUpdates(
481481
]);
482482
$updated_message = $this->getDevicePathSend() . $update["id"] . "." . $update["status"];
483483
rename($message_array[0], $updated_message);
484+
touch($updated_message);
484485
}
485486
}
486487
}

0 commit comments

Comments
 (0)