-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMSClass.php
718 lines (662 loc) · 15.5 KB
/
SMSClass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
<?php
namespace SMSClasses;
/**
* Send SMS by gate
*
* @package php-sms-classes
* @author Rafal Zielonka
* @link <https://github.com/Bombaharris/php-sms-classes>
* @copyright Copyright (C) 2012 Rafał Zielonka
* @license This program is free software:
* you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* @filesource
*/
interface SMSable
{
/**
* Method send request to gate with all data needed to send SMS
*/
public function send();
/**
* Method send request to gate with all data needed to obtain inforamtion
* about sended SMS
*/
public function info();
/**
* Method send request to gate with all data needed to confirm SMS
*/
public function confirm();
/**
* Method send request to gate with all data needed to get SMS
*/
public function get();
/**
* Method parse gate response
*/
public function explainResponse();
/**
* Method return action status ie. send() info()
*/
public function getActionStatus();
}
/**
* PHP class build to send SMS by Gate
*
* @author Rafał Zielonka
* @version 1.0
*
* @property string $_gateUrl SMS gate url
* @property string $_gateUser SMS gate user
* @property string $_gatePassword SMS gate password
* @property string $_gateServiceId SMS gate service numeric identifier
* @property string $_text SMS text
* @property string $_telephoneNumber reciever telephone number
* @property string $_numberPrefix reciver telephone number prefix
* @property string $_originator alphanumeric originator address
* (up to 11 characters)
* @property integer $_dispatchId Service/dispatch numeric identifier
* @property string $_validTo date
* @property boolean $_delivNotifRequest delivery notify request from SMSC
* @property boolean $_zeroclass indicates that this message is to be displayed
* on the MS immediately and a message delivery
* report is to be sent back to the SMSC
* @property boolean $_advancedEncoding indicates if the SMS
* will be encoded with UTF-8
* @property boolean $_deleteContent request for SMS
* content removal from SMS gate database
* @property integer $_smsId SMS numeric identifier
* @property integer $_timeout timeout time in microseconds
* @property boolean $_manualConfirm set manual confirm while getting sms
* @property string $_sslCertPath path to cert file
* @property string $_sslCertPass pass to cert file
* @property string $_schedule time when sms gonna be send
* @property integer $actionStatus unified action status (-1,0,1)
* @property array $response contains gate response info
*
*/
class SMS
{
/**
* @desc status code while error was detected during action
*/
const ACTION_STATUS_ERROR = -1;
/**
* @desc status code while action fail
*/
const ACTION_STATUS_FAIL = 0;
/**
* @desc status code while action succeed
*/
const ACTION_STATUS_SUCCESS = 1;
/**
* @desc array key for action status
*/
const KEY_ACTION_STATUS = 'actionStatus';
/**
* @desc array key for gate response status
*/
const KEY_RESPONSE_STATUS = 'responseStatus';
/**
* @desc array key for error code
*/
const KEY_ERROR_CODE = 'errorCode';
/**
* @desc array key for sms identifier
*/
const KEY_SMS_ID = 'id';
/**
* @desc array key for sms type
*/
const KEY_TYPE = 'type';
/**
* @desc array key for sms text
*/
const KEY_TEXT = 'text';
/**
* @desc array key for protocol nuemric identifier
*/
const KEY_PROTOCOL_ID = 'protocolId';
/**
* @desc array key for chareset scheme identifier
*/
const KEY_CHARSET_SCHEME_ID = 'charsetSchemeId';
/**
* @desc array key for connector identifier
*/
const KEY_CONNECTOR_ID = 'connectorId';
/**
* @desc array key for service identifier
*/
const KEY_SERVICE_ID = 'serviceId';
/**
* @desc array key for incoming sms identifier
*/
const KEY_SMS_IN_ID = 'smsInId';
/**
* @desc array key for SMS priority
*/
const KEY_PRIORITY = 'priority';
/**
* @desc array key for SMS send datetime
*/
const KEY_SEND_DATE = 'sendDate';
/**
* @desc array key for SMS date
*/
const KEY_VALID_TO_DATE = 'validToDate';
/**
* @desc array key for delivery notify request flag
*/
const KEY_DELIV_NOTIF_REQUEST = 'delivNotifRequest';
/**
* @desc array key for SMS originator
*/
const KEY_ORIG = 'orig';
/**
* @desc array key for SMS destination
*/
const KEY_DEST = 'dest';
/**
* @desc array key for SMS status
*/
const KEY_STATUS = 'status';
/**
* @desc array key for SMS status change date
*/
const KEY_STATUS_CHANGE_DATE = 'statusChangeDate';
/**
* @desc array key for SMS status change date
*/
const KEY_SMSC_RECIVED_DATE = 'smscRecivedDate';
/**
* @desc array key for operator identifier
*/
const KEY_OPERATOR_ID = 'operatorId';
/**
* @desc array key for multi part SMS type
*/
const KEY_MPART_TYPE = 'mPartType';
/**
* @desc array key for multi part SMS number of parts
*/
const KEY_MPART_PARTS = 'mPartParts';
/**
* @desc array key for multi part SMS identifier
*/
const KEY_MPART_ID = 'mPartId';
/**
* @desc array key for multi part SMS part number
*/
const KEY_MPART_NO = 'mPartNo';
/**
* @desc array key for multi part SMS max part numbers
*/
const KEY_MPART_MAX = 'mPartMax';
protected $_gateUrl = null;
protected $_gateUser = null;
protected $_gateServiceId = null;
protected $_gatePassword = null;
protected $_text = null;
protected $_telephoneNumber = null;
protected $_numberPrefix = null;
protected $_originator = null;
protected $_dispatchId = 10;
protected $_validTo = null;
protected $_delivNotifRequest = false;
protected $_zeroclass = false;
protected $_advancedEncoding = false;
protected $_deleteContent = false;
protected $_smsId = null;
protected $_timeout = 30000;
protected $_manualConfirm = false;
protected $_sslCertPath = null;
protected $_sslCertPass = null;
protected $_schedule = null;
public $actionStatus = 0;
public $response = array(
'status' => null,
'error' => false,
'data' => array(),
);
public $dataExplained = array();
/**
* Magic method
*
* @return string response status
*/
function __toString()
{
return (string) $this->response['status'];
}
/**
* Get SMS gate URL
*
* @return string
*/
public function getGateURL()
{
return $this->_gateUrl;
}
/**
* Set SMS gate URL
*
* @param string $_gateUrl
* @return \SMS
*/
public function setGateURL($_gateUrl)
{
$this->_gateUrl = $_gateUrl;
return $this;
}
/**
* Get SMS gate user name
*
* @return string
*/
public function getGateUser()
{
return $this->_gateUser;
}
/**
* Set SMS gate user name
*
* @param string $_gateUser
* @return \SMS
*/
public function setGateUser($_gateUser)
{
$this->_gateUser = $_gateUser;
return $this;
}
/**
* Get SMS gate password
*
* @return string
*/
public function getGatePassword()
{
return $this->_gatePassword;
}
/**
* Set SMS gate password
*
* @param string $_gatePassword
* @return \SMS
*/
public function setGatePassword($_gatePassword)
{
$this->_gatePassword = $_gatePassword;
return $this;
}
/**
* Get SMS service numeric identifier
*
* @return string
*/
public function getGateServiceId()
{
return $this->_gateServiceId;
}
/**
* Set SMS service numeric identifier
*
* @param string $gate_service_id
* @return \SMS
*/
public function setGateServiceId($gateServiceId)
{
$this->_gateServiceId = $gateServiceId;
return $this;
}
/**
* Get SMS message
*
* @return string
*/
public function getText()
{
return $this->_text;
}
/**
* Set SMS message
*
* @param string $_text
* @return \SMS
*/
public function setText($_text)
{
$this->_text = $_text;
return $this;
}
/**
* Get SMS reciver telephone number
*
* @return string
*/
public function getTelephoneNumber()
{
return $this->_telephoneNumber;
}
/**
* Set SMS reciver telephone number
*
* @param string $_telephoneNumber
* @return \SMS
*/
public function setTelephoneNumber($_telephoneNumber)
{
$this->_telephoneNumber = $_telephoneNumber;
return $this;
}
/**
* Get SMS reciver telephone number prefix
*
* @return string
*/
public function getNumberPrefix()
{
return $this->_numberPrefix;
}
/**
* Set SMS reciver telephone number prefix
*
* @param string $_numberPrefix
* @return \SMS
*/
public function setNumberPrefix($_numberPrefix)
{
$this->_numberPrefix = $_numberPrefix;
return $this;
}
/**
* Get originator
*
* @return string
*/
public function getOriginator()
{
return $this->_originator;
}
/**
* Set originator
*
* @param string $_originator alphanumeric originator address
* (up to 11 characters)
* @return \SMS
*/
public function setOriginator($_originator)
{
$this->_originator = $_originator;
return $this;
}
/**
* Get dispatch numeric identifier
*
* @return integer
*/
public function getDispatchId()
{
return (int) $this->_dispatchId;
}
/**
* Set dispathc numeric identifier
*
* @param integer $_dispatch_id
* @return \SMS
*/
public function setDispatchId($_dispatchId)
{
$this->_dispatchId = (int) $_dispatchId;
return $this;
}
/**
* Get valid to date
*
* @return string
*/
public function getValidTo()
{
return $this->_validTo;
}
/**
* Set valid to date
*
* @param string $_valid_to
* @return \SMS
*/
public function setValid_to($_validTo)
{
$this->_validTo = $_validTo;
return $this;
}
/**
* Set flag for delivery notify request from SMSC
*
* @return boolean
*/
public function isDelivNotifRequest()
{
return (bool) $this->_delivNotifRequest;
}
/**
* Get flag for delivery notify request from SMSC
*
* @param boolean $_delivNotifRequest
* @return \SMS
*/
public function setDelivNotifRequest($_delivNotifRequest)
{
$this->_delivNotifRequest = $_delivNotifRequest;
return $this;
}
/**
* Get flag for zeroclass message
*
* @return boolean
*/
public function isZeroClass()
{
return (bool) $this->_zeroclass;
}
/**
* Set flag for zeroclass message
*
* @return \SMS
*/
public function setZeroClass($zeroclass)
{
$this->_zeroclass = $zeroclass;
return $this;
}
/**
* Get flag for advanced encoding
*
* @return boolean
*/
public function isAdvancedEncoding()
{
return (bool) $this->_advancedEncoding;
}
/**
* Set flag for advanced encoding in utf-8
* @desc decrase SMS chars limit to 70 chars
*
* @param boolean $_advancedEncoding
* @return \SMS
*/
public function setAdvancedEncoding($_advancedEncoding)
{
$this->_advancedEncoding = $_advancedEncoding;
return $this;
}
/**
* Get flag for delete content
*
* @return boolean
*/
public function isDeleteContent()
{
return (bool) $this->_deleteContent;
}
/**
* Set flag for delete content
*
* @param boolean $_deleteContent
* @return \SMS
*/
public function setDeleteContent($_deleteContent)
{
$this->_deleteContent = $_deleteContent;
return $this;
}
/**
* Get SMS numeric indentifier
*
* @return integer
*/
public function getSMSId()
{
return (int) $this->_smsId;
}
/**
* Set SMS numeric indentifier
*
* @param integer $_smsId
* @return \SMS
*/
public function setSMSId($_smsId)
{
$this->_smsId = $_smsId;
return $this;
}
/**
* Get timeout
*
* @return integer
*/
public function getTimeout()
{
return (int) $this->_timeout;
}
/**
* Set timeout
*
* @param integer $_timeout
* @return \SMS
*/
public function setTimeout($_timeout)
{
$this->_timeout = $_timeout;
return $this;
}
/**
* Get manual confirm
*
* @return boolean
*/
public function isManualConfirm()
{
return $this->_manualConfirm;
}
/**
* Set manual confirm while getting SMS
*
* @param boolean $_manualConfirm
* @return \SMS
*/
public function setManualConfirm($_manualConfirm)
{
$this->_manualConfirm = $_manualConfirm;
return $this;
}
/**
* Get cert path
*
* @return string
*/
public function getSslCertPath()
{
return $this->_sslCertPath;
}
/**
* Set cert path
*
* @param string $_sslCertPath
* @return \SMS
*/
public function setSslCertPath($_sslCertPath)
{
$this->_sslCertPath = $_sslCertPath;
return $this;
}
/**
* Get cert password
*
* @return string
*/
public function getSslCertPass()
{
return $this->_sslCertPass;
}
/**
* Set cert password
*
* @param string $_sslCertPass
* @return \SMS
*/
public function setSslCertPass($_sslCertPass)
{
$this->_sslCertPass = $_sslCertPass;
return $this;
}
/**
* Get send time
*
* @return string
*/
public function getSchedule()
{
return $this->_schedule;
}
/**
* Set send time
*
* @param string $_schedule DateTime construct string i.e.(+ 2 minutes)
* @return \SMS
*/
public function setSchedule($_schedule)
{
$this->_schedule = $_schedule;
return $this;
}
/**
* Returns unified array.
*
* @return array
*/
public function explainResponse()
{
return $this->dataExplained;
}
/**
* Returns action status
*
* @return integer
*/
public function getActionStatus()
{
return $this->actionStatus;
}
}