-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathussdap.php
executable file
·295 lines (265 loc) · 8.93 KB
/
ussdap.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
<?php
ini_set('error_log', 'ussd-app-error.log');
require 'libs/MoUssdReceiver.php';
require 'libs/MtUssdSender.php';
require 'class/operationsClass.php';
//require 'log.php';
require 'db.php';
$production=false;
if($production==false){
$ussdserverurl ='http://localhost:7000/ussd/send';
}
else{
$ussdserverurl= 'https://api.dialog.lk/ussd/send';
}
$receiver = new UssdReceiver();
$sender = new UssdSender($ussdserverurl,'APP_000001','password');
$operations = new Operations();
$receiverSessionId = $receiver->getSessionId();
$content = $receiver->getMessage(); // get the message content
$address = $receiver->getAddress(); // get the sender's address
$requestId = $receiver->getRequestID(); // get the request ID
$applicationId = $receiver->getApplicationId(); // get application ID
$encoding = $receiver->getEncoding(); // get the encoding value
$version = $receiver->getVersion(); // get the version
$sessionId = $receiver->getSessionId(); // get the session ID;
$ussdOperation = $receiver->getUssdOperation(); // get the ussd operation
$responseMsg = array(
"main" =>
"Wecome! Choose language:
1. አማርኛ
2. English
3. IVR
0. Exit",
"amharic" =>
"ሥራ ዘርፍ:
1. ግንባታ
2. ቴክኖዎሎጂ መረጃ
3. ግብርና
4. የተሰራበት
5. ሆቴል
6. ሒሳብ
0. Exit",
"english"=>
"Job Sector:
1.Construction
2.Information Technology
3.Agriculture
4.Manufacturing
5.Hotel
6.Accounting",
"aList1"=>
"ግንባታ:
1. ከያኒ ንድፍ
2. የቅርፀት መሃንዲስ
3. የአቋም መሃንዲስ
4. ግምበኛ
5. ሠዓሊ
6. አናፂ",
"eList1"=>
"Construction:
1. Architect
2. architectural engineer
3. structural engineer
4. construction worker
5. Painter
6. carpenter",
"aList2"=>
"ቴክኖዎሎጂ መረጃ:
1. ኮምፒውተር መሃንዲስ
2. መረብ መሃንዲስ
3. ምእላድ አስተዳዳሪ
",
"eList2"=>
"Information technology:
1. Developer
2. Database manager
3. Network specialist
",
"aList3"=>
"ግብርና :
1. ገበሬ
2. ዐጃቢ
3. ደንገጥር",
"eList3"=>
"Agriculture :
1. Farmer
2. poultry worker
3. livestock",
"eList4"=>
"Manufacturing:
No job.
",
"aList5"=>
"ሆቴል:
አይ ሥራ
",
"eList5"=>
"Hotel:
No job.
",
"aList6"=>
"ሒሳብ:
አይ ሥራ
",
"eList6"=>
"Accounting:
No job.
"
);
$jobdescription = array(
"english" => "Jobtitle
the job description is where
we discribe the job skills need
and other stuff.
",
"amharic" => "ሥራ አርእስት
ሥራ አገላለጽ ነው የት እኛ ገለፀ ሥራ
ጉብዝና ተፈላጊ እና ሌላ እቃ ሥራ
አገላለጽ ነው የት እኛ ገለፀ ሥራ
ጉብዝና ተፈላጊ እና ሌላ እቃ
"
);
if ($ussdOperation == "mo-init") {
try {
$sessionArrary=array( "sessionid"=>$sessionId,"tel"=>$address,"menu"=>"main","pg"=>"","others"=>"");
$operations->setSessions($sessionArrary,$db);
$sender->ussd($sessionId, $responseMsg["main"],$address );
} catch (Exception $e) {
$sender->ussd($sessionId, 'Sorry error occured try again',$address );
}
}else {
$flag=0;
$joba = array("aList1","aList2","aList3","aList4","aList5","aList6");
$jobe = array("eList1","eList2","eList3","eList4","eList5","eList6");
$sessiondetails= $operations->getSession($sessionId,$db);
$cuch_menu=$sessiondetails['menu'];
if(in_array($cuch_menu,$joba)){
$cuch_menu = "joba";
}elseif(in_array($cuch_menu,$jobe)){
$cuch_menu = "jobe";
}
$operations->session_id=$sessiondetails['sessionsid'];
switch($cuch_menu ){
case "main": // Following is the main menu
switch ($receiver->getMessage()) {
case "1":
$operations->session_menu="amharic";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["amharic"],$address );
break;
case "2":
$operations->session_menu="english";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["english"],$address );
break;
case "3":
$operations->session_menu="ivr";
$operations->saveSesssion($db);
$sender->ussd($sessionId,'Enter Your ID',$address );
break;
default:
$operations->session_menu="main";
$operations->saveSesssion($db);
$sender->ussd($sessionId, $responseMsg["main"],$address );
break;
}
break;
case "amharic":
switch ($receiver->getMessage()) {
case "1":
$operations->session_menu="aList1";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["aList1"],$address );
break;
case "2":
$operations->session_menu="aList2";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["aList2"],$address );
break;
case "3":
$operations->session_menu="aList3";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["aList3"],$address );
break;
case "4":
$operations->session_menu="aList4";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["aList4"],$address );
break;
case "5":
$operations->session_menu="aList5";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["aList5"],$address );
break;
case "6":
$operations->session_menu="aList6";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["aList6"],$address );
break;
default:
$operations->session_menu="amharic";
$operations->saveSesssion($db);
$sender->ussd($sessionId, $responseMsg["amharic"],$address );
break;
}
break;
case "english":
switch ($receiver->getMessage()) {
case "1":
$operations->session_menu="eList1";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["eList1"],$address );
break;
case "2":
$operations->session_menu="eList2";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["eList2"],$address );
break;
case "3":
$operations->session_menu="eList3";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["eList3"],$address );
break;
case "4":
$operations->session_menu="eList4";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["eList4"],$address );
break;
case "5":
$operations->session_menu="eList5";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["eList5"],$address );
break;
case "6":
$operations->session_menu="eList6";
$operations->saveSesssion($db);
$sender->ussd($sessionId,$responseMsg["eList6"],$address );
break;
default:
$operations->session_menu="english";
$operations->saveSesssion($db);
$sender->ussd($sessionId, $responseMsg["amharic"],$address );
break;
}
break;
case "ivr":
$sender->ussd($sessionId,'You Purchased a large T-Shirt Your ID '.$receiver->getMessage(),$address ,'mt-fin');
break;
case "joba":
$operations->session_menu="main";
$operations->saveSesssion($db);
$sender->ussd($sessionId, $jobdescription["amharic"],$address );
break;
case "jobe":
$operations->session_menu="main";
$operations->saveSesssion($db);
$sender->ussd($sessionId, $jobdescription["english"],$address );
break;
default:
$operations->session_menu="main";
$operations->saveSesssion($db);
$sender->ussd($sessionId,'Incorrect option',$address );
break;
}
}