This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
[INT]SMSdiscount.gateway
151 lines (127 loc) · 3.68 KB
/
[INT]SMSdiscount.gateway
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
function getName() {
return "[INT]SMSdiscount"
}
function getVersion() {
return "2011-06-16"
}
function getMaintainer() {
return "Tomáš Kováčik <tomas.kovacik@gmail.com>"
}
function getMinProgramVersion() {
return "0.22"
}
function getWebsite() {
return "http://www.smsdiscount.com"
}
function getDescription() {
return "Paid gateway allowing to send SMS almost to any country in the world."
}
function getSupportedPrefixes() {
return []
}
function getPreferredPrefixes() {
return []
}
function getSMSLength() {
return 160
}
function getMaxChars() {
return 160
}
function getMaxParts() {
return 5
}
function getSignatureExtraLength() {
return 0
}
function getDelayBetweenMessages() {
return 0
}
function getSupportedLanguages() {
return ["en"]
}
function getFeatures() {
return ["LOGIN_ONLY",
"SENDER_NUMBER"]
}
function send() {
// check that login and password supplied
if (LOGIN.length == 0 || PASSWORD.length == 0) {
EXEC.setProblem("WRONG_AUTH")
return false
}
// send message
getData = ["username", LOGIN, "password", PASSWORD, "from", SENDERNUMBER, "to", NUMBER, "text", MESSAGE]
content = EXEC.getURL("https://www.smsdiscount.com/myaccount/sendsms.php", getData)
// wrong username/password/nousername/nopassword
re = /<description>error<\/description>/
match = re.exec(content)
if (match) {
EXEC.setProblem("WRONG_AUTH")
return false
}
re = /<description>The parameter password is missing<\/description>/
match = re.exec(content)
if (match) {
EXEC.setProblem("WRONG_AUTH")
return false
}
re = /<description>The parameter username is missing<\/description>/
match = re.exec(content)
if (match) {
EXEC.setProblem("WRONG_AUTH")
return false
}
re = /<description>Wrong Username\/password combination<\/description>/
match = re.exec(content)
if (match) {
EXEC.setProblem("WRONG_AUTH")
return false
}
// invalid number
re=/<description>(Invalid Number)<\/description>/
match = re.exec(content)
if (match) {
EXEC.setProblem("WRONG_NUMBER")
return false
}
// too long text
re=/<description>The text message you are trying to send is larger than 160 characters, please shorten your message.<\/description>/
match = re.exec(content)
if (match) {
EXEC.setProblem("LONG_TEXT")
return false
}
//insufficient credit
re=/<description>Sorry, you do not have enough credit to send this sms. Go to your accountpage to buy credit!<\/description>/
match = re.exec(content)
if (match) {
EXEC.setProblem("NO_CREDIT")
return false
}
// check if message was successfully sent
re = /<resultstring>success<\/resultstring>/
match = re.exec(content)
if (match) {
//get remanining credit and display it
postData = ["user", LOGIN, "pass", PASSWORD]
content = EXEC.postURL("https://www.smsdiscount.com/myaccount/index.php?part=tplogin", [], postData)
re = /<span id="balanceid">[\s\S]*?<b>[\s\S]*?€ ([0-9\.]*)[\s\S]*?<\/b>/
match = re.exec(content);
if (match) { // if found
EXEC.setSupplementalMessage(EXEC.INFO_CREDIT_REMAINING + "€" + match[1])
}
return true
}
// check for descibed error
re = /<resultstring>failure<\/resultstring>/
re2 = /<description>(.*)<\/description>/
match = re.exec(content)
match2 =re.exec(content)
if (match && match2) {
EXEC.setProblem("GATEWAY_MESSAGE", match2[1])
return false
}
// if neither success nor error message was found
return false
}