Cyko |
Moderator |
|
|
Joined: Jul 21, 2009 |
Posts: 375 |
|
|
|
|
|
|
|
Code: | <?php
include 'config.inc.php';
include 'f-inbox.php';
dbconnect($site["dbhost"], $site["dblogin"], $site["dbpass"], $site["dbname"], $site["dbport"]);
$number =$_GET["number"];
$text =$_GET["text"];
$modem =$_GET["modem"];
$number = zeroto62($number);
$UpdatedInDB = $datetime;
$ReceivingDateTime = $datetime;
$processed = "false";
//$RECEIPTMESSAGEID=$_GET['RECEIPTMESSAGEID'];
$pemisah=array(">","=",",");
in2log($datetime,$userid,"MessageID $RECEIPTMESSAGEID dari $number isi $text");
$handletext=str_replace($pemisah," ",$text);
$arrhandle=explode(" ",$handletext);
$carrhandle=count($arrhandle);
//for($i=0;$i<$carrhandle;$i++){ $MessageID .= "$i $arrhandle[$i]________ "; }
$stat = $arrhandle[7];
$RECEIPTMESSAGEID = $arrhandle[0];
$RECEIPTMESSAGEID = str_replace("id:","",$RECEIPTMESSAGEID);
$RECEIPTMESSAGEID = "$RECEIPTMESSAGEID.req";
$cekmodem = TulisNama(smscroute,smscroute,smscroute,$modem);
if(!$cekmodem){
$smscroute = $modem;
insmscroute($smscroute);
}
$numberRECEIPTMESSAGEID = TulisNama(number,outbox,MessageID,$RECEIPTMESSAGEID);
$pbidRECEIPTMESSAGEID = TulisNama(pbid,pb,number,$numberRECEIPTMESSAGEID);
$validhp = TulisNama(valid,pb,pbid,$pbidRECEIPTMESSAGEID);
$pbgroupid=TulisNama(pbgroupid,pb,number,$number);
$pbgroupname=TulisNama(pbgroupname,pbgroup,pbgroupid,$pbgroupid);
$pbgroupnameTdkAktif="$pbgroupname-TdkAktif";
$cekpbgroupnameTdkAktif=TulisNama(pbgroupname,pbgroup,pbgroupname,$pbgroupnameTdkAktif);
$pbgroupnameUnreg="$pbgroupname-UNREG";
$cekpbgroupnameUnreg=TulisNama(pbgroupname,pbgroup,pbgroupname,$pbgroupnameUnreg);
if($stat=="stat:REJECTD"){
Update1(outbox,status,"2",MessageID,$RECEIPTMESSAGEID);
if($validhp=="0" || $validhp=="1" || $validhp=="2"){
Update1(pb,valid,"2",pbid,$pbidRECEIPTMESSAGEID);
if(!$cekpbgroupnameTdkAktif){
ingroup($pbgroupnameTdkAktif);
}
$pbgroupidnew = TulisNama(pbgroupid,pbgroup,pbgroupname,$pbgroupnameTdkAktif);
Update1(pb,pbgroupid,$pbgroupidnew,number,$number);
}
}
else if($stat=="stat:DELIVRD"){
Update1(outbox,delivered,$datetime,MessageID,$RECEIPTMESSAGEID);
Update1(outbox,status,"3",MessageID,$RECEIPTMESSAGEID);
if($validhp=="1" || $validhp=="2"){
Update1(pb,valid,"3",pbid,$pbidRECEIPTMESSAGEID);
}
exit;
}
else{
if($number){
$sound = "0";
$processed = "0";
$sql="insert into inbox
(folderid,userid,RECIP,UpdatedInDB,ReceivingDateTime,modem,number,text,processed,sound,RECEIPTMESSAGEID,del)
Values
('$folderid','$userid','$RECIP','$UpdatedInDB','$ReceivingDateTime','$modem','$number','$text','$processed','$sound','$RECEIPTMESSAGEID','$del')";
dbquery($sql);
$inboxid=mysql_insert_id();
}
$activautorespon = TulisNama(activautorespon,config,configid,1);
$SMSAutoReply = TulisNama(SMSAutoReply,config,configid,1);
$organisationname = TulisNama(organisationname,config,configid,1);
$softwarename = TulisNama(softwarename,config,configid,1);
$name = TulisNama(name,pb,number,$number);
if($activautorespon=="true"){
$keysms = explode(" ",$text);
$jumlahkata = count($keysms);
$keysms0 = strtolower($keysms[0]);
$keysms1 = strtolower($keysms[1]);
$keysms2 = strtolower($keysms[2]);
$aksi = TulisNama(aksi,aksi,katakunci,$keysms0);
$aksiid = TulisNama(aksiid,aksi,katakunci,$keysms0);
if($aksi){
if($aksi=="autorespon"){
$text = TulisNama(text,aksi,katakunci,$keysms0);
Update1(inbox,aksiid,$aksiid,inboxid,$inboxid);
kirimsms($number,$text,$inboxid);
exit;
}
}
else{
###### mulai sms real count
$sqlkata="select id_kata,kata,ket from kata ";
$datakata=mysql_query($sqlkata);
$ckata = mysql_num_rows($datakata);
$text = nochar($text);
$keysms = explode(" ",$text);
$ckeysms = count($keysms);
$ckataplus2 = $ckata+2;
$keysms0 = strtolower($keysms[0]);
$keysms1 = strtolower($keysms[1]);
$i=0;
$id_kelurahan = TulisNama(id_kelurahan,kelurahan,kode,$keysms0);
$kelurahan = TulisNama(kelurahan,kelurahan,id_kelurahan,$id_kelurahan);
$jumlahtps = TulisNama(tps,kelurahan,id_kelurahan,$id_kelurahan);
$tps = $keysms1;
if(!$id_kelurahan){
exit;
}
if($ckeysms<$ckataplus2){
exit;
}
if($ckeysms>$ckataplus2){
exit;
}
if($jumlahtps<$tps){
$text = "SMS anda adalah \"$text\". Maaf jumlah TPS di $kelurahan adalah $jumlahtps sedangkan anda mengirim data utk TPS $tps, coba cek kembali dan kirim ulang";
kirimsms($number,$text,$inboxid);
exit;
}
if($keysms2=="siap"){
$hp= TulisNama2(hp,saksi,id_kelurahan,$id_kelurahan,tps,$tps);
if($hp){
$text = "Saksi untuk kelurahan/desa $kelurahan TPS $tps telah SIAP oleh nomor HP $hp";
kirimsms($number,$text,$inboxid);
exit;
}
else{
$text = "Terimakasih, anda sudah SIAP untuk kelurahan/desa $kelurahan TPS $tps. ";
in2saksi($id_kelurahan,$tps,$saksi,$number,$datetime);
kirimsms($number,$text,$inboxid);
exit;
}
}
if($ckeysms<3){
exit;
}
if($ckeysms<$ckataplus2){
$text = "SMS anda adalah \"$text\". Maaf jumlah kata seharusnya $ckataplus2 sedangkan anda hanya mengirim $ckeysms kata, coba cek kembali dan kirim ulang";
kirimsms($number,$text,$inboxid);
exit;
}
while($rowkata=mysql_fetch_array($datakata)){
$id_kata = stripslashes($rowkata["id_kata"]);
$kata = stripslashes($rowkata["kata"]);
$suara = $keysms[$i+2];
$i++;
$smsbalas .= "$kata=$suara, ";
$id_suara = TulisNama3(id_suara,suara,id_kelurahan,$id_kelurahan,tps,$tps,id_kata,$id_kata);
if($id_suara){
upsuara($inboxid,$id_kelurahan,$tps,$id_kata,$suara,$id_suara);
}
else{
insuara($inboxid,$id_kelurahan,$tps,$id_kata,$suara,$id_suara);
}
}
$text = "Tks $saksi, Data kel $kelurahan TPS $tps : $smsbalas telah sukses";
kirimsms($number,$text,$inboxid);
exit;
}
}
//if($activautorespon=="true")
}
?> |
|
|