-
Notifications
You must be signed in to change notification settings - Fork 2
/
fn-telek.php
127 lines (106 loc) · 4.04 KB
/
fn-telek.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
<?php
defined('_SECURE_') or die('Forbidden');
/*
function telek_checkavailablekeyword($keyword){
$ok = true;
$db_query = "SELECT subscribe_id FROM " . _DB_PREF_ . "_featureSubscribe WHERE subscribe_keyword='$keyword'";
if ($db_result = dba_num_rows($db_query)) {
$ok = false;
}
return $ok;
}
*/
/*
* intercept incoming sms and remove keyword
*
* @param $sms_datetime
* incoming SMS date/time
* @param $sms_sender
* incoming SMS sender
* @message
* incoming SMS message before interepted
* @param $sms_receiver
* receiver number that is receiving incoming SMS
* @return
* array $ret
*/
function telek_hook_setsmsincomingaction($sms_datetime, $sms_sender, $message, $sms_receiver) {
$ok = false;
//$uid = user_mobile2uid($sms_sender);
// $db_query = "SELECT * FROM " . _DB_PREF_ . "_featureSubscribe WHERE subscribe_keyword='$subscribe_keyword'";
// $db_result = dba_query($db_query);
//if ($db_row = dba_fetch_array($db_result)) {
//if ($db_row['uid'] && $db_row['subscribe_enable']) {
if ($sms_sender && $message) {
_log('begin s:' . $sms_sender . ' m:' . $message, 2, 'telek');
// if (sms_subscribe_handle($db_row, $sms_datetime, $sms_sender, $subscribe_keyword, $subscribe_param, $sms_receiver, $smsc, $raw_message)) {
$ok = true;
// }
$status = ($ok ? 'handled' : 'unhandled');
_log('end s:' . $sms_sender . ' m:' . $message . ' s:' . $status, 2, 'telek');
}
//}
//$ret['uid'] = user_mobile2uid($sms_sender);
$ret['status'] = $ok;
return $ret;
}
function telek_hook_recvsms_intercept($sms_datetime, $sms_sender, $message, $sms_receiver){
//$ret = array();
$ps= explode(" ", $message,2);
$ikut = strtoupper($ps[0]);
//$pesan = '';
$hooked = false;
if($ikut == 'DAFTAR'){
$pecah= preg_split("/#/", $ps[1], null, PREG_SPLIT_NO_EMPTY );
$c_uid = user_mobile2uid($sms_sender);
$data = array();
$data['name'] = trim($pecah[0]);
$data['username'] = trim($pecah[1]);
$data['mobile'] = $sms_sender;
$data['email'] = $data['name']."@noreply.org";
$data['parent_uid'] = 0;
$data['status'] = 4;
}
if($nama && $nohp && $pengguna){
logger_print("*******", 3, "telek");
logger_print("sms_sender " . $sms_sender, 3, "telek");
logger_print("message " . $message, 3, "telek");
logger_print("new message " . $nama, 3, "telek");
logger_print("sms target user" . $sms_receiver, 3, "telek");
logger_print("*******", 3, "telek");
if (($uid = user_mobile2uid($sms_sender)) && $nama) {
_log("save in inbox u:" . $username . " uid:" . $uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:[" . $nohp . "]", 3, 'telek');
//recvsms_inbox_add($sms_datetime, $sms_sender, $username, $nama, $sms_receiver);
//$hooked = true;
//$status = ($ok ? 'handled' : 'unhandled');
}
}
//// $ret['uid'] = user_mobile2uid($sms_sender);
//// $ret['status'] = TRUE;
// $ret['param']['message'] = $ikut . ' ' . $nama .' '. $nohp . ' ' . $pengguna;
// $ret['modified'] = TRUE;
// $ret['hooked'] = TRUE;
$ret = user_add($data);
$ok = ($ret['status'] ? TRUE : FALSE );
if ($ok){
echo "okee";
$items = array(
'uid' => 1,
'name' => $data['name'],
'mobile' => $data['mobile'],
'email' => $data['email'],
'tags' => $tags
);
if ($c_pid = dba_add(_DB_PREF_ . '_featurePhonebook', $items)) {
$save_to_group = TRUE;
} else {
logger_print('fail to add contact pid:' . $c_pid . ' m:' . $mobile . ' n:' . $name . ' e:' . $email . ' tags:[' . $tags . ']', 3, 'phonebook_add');
}
}else{
echo "gagal";
}
return $ret;
}
/*
function telek_handle(){
}*/