summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Duedal <hd@onlinecity.dk>2011-10-04 14:04:14 +0200
committerHans Duedal <hd@onlinecity.dk>2011-10-04 14:04:14 +0200
commita3bf5e6fd01274cbe5e9b9dfdee2fd96919009a6 (patch)
treef55721878a9fab6a918f074bd71899a613e89370
parente1e00781f61c608b21764183b265907482a2e66d (diff)
downloadphp-smpp-a3bf5e6fd01274cbe5e9b9dfdee2fd96919009a6.zip
php-smpp-a3bf5e6fd01274cbe5e9b9dfdee2fd96919009a6.tar.gz
php-smpp-a3bf5e6fd01274cbe5e9b9dfdee2fd96919009a6.tar.bz2
Improve reg.exp. parsing of delivery receipts
Relaxed case sensitive to insensitive. Added support for timestamps with seconds. These changes are made to support Vodacom (South Africa), which are non-standard.
-rw-r--r--smppclient.class.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/smppclient.class.php b/smppclient.class.php
index 1d6fd53..521ae97 100644
--- a/smppclient.class.php
+++ b/smppclient.class.php
@@ -962,7 +962,7 @@ class SmppDeliveryReceipt extends SmppSms
*/
public function parseDeliveryReceipt()
{
- $numMatches = preg_match('/^id:([^ ]+) sub:(\d{1,3}) dlvrd:(\d{3}) submit date:(\d{10}) done date:(\d{10}) stat:([A-Z]{7}) err:(\d{3}) text:(.*)$/ms', $this->message, $matches);
+ $numMatches = preg_match('/^id:([^ ]+) sub:(\d{1,3}) dlvrd:(\d{3}) submit date:(\d{10,12}) done date:(\d{10,12}) stat:([A-Z]{7}) err:(\d{3}) text:(.*)$/si', $this->message, $matches);
if ($numMatches == 0) {
throw new InvalidArgumentException('Could not parse delivery receipt: '.$this->message."\n".bin2hex($this->body));
}
@@ -970,9 +970,9 @@ class SmppDeliveryReceipt extends SmppSms
// Convert dates
$dp = str_split($this->submitDate,2);
- $this->submitDate = gmmktime($dp[3],$dp[4],0,$dp[1],$dp[2],$dp[0]);
+ $this->submitDate = gmmktime($dp[3],$dp[4],isset($dp[5]) ? $dp[5] : 0,$dp[1],$dp[2],$dp[0]);
$dp = str_split($this->doneDate,2);
- $this->doneDate = gmmktime($dp[3],$dp[4],0,$dp[1],$dp[2],$dp[0]);
+ $this->doneDate = gmmktime($dp[3],$dp[4],isset($dp[5]) ? $dp[5] : 0,$dp[1],$dp[2],$dp[0]);
}
}