Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //--- Proses SMS
- $sql="SELECT COUNT(1) AS num
- FROM dacal";
- $result=mysql_query($sql) or die(mysql_error());
- $cal=mysql_fetch_object($result);
- mysql_free_result($result);
- $sql="SELECT a.id,a.sendernumber,b.noHP AS sendnum, a.textdecoded
- FROM inbox a
- LEFT JOIN tps b ON b.noHP=REPLACE(a.sendernumber,'+62','0')
- WHERE a.processed='false'";
- $result=mysql_query($sql);
- if(mysql_num_rows($result)>0)
- {
- while($record=mysql_fetch_object($result))
- {
- if(!empty($record->sendnum))
- {
- $sms=explode(" ", $record->textdecoded);
- $sql='';
- if($sms[0]=='QC')
- {
- $strsql=array();
- $kondisi=true;
- for($i=1;$i<=$cal->num;$i++)
- {
- $kondisi= $kondisi && (is_numeric($sms[$i])?((int)$sms[$i]<0?false:true):false);
- $strsql[]="calon".$i."='".$sms[$i]."' ";
- }
- if($kondisi){
- $sql="UPDATE tps SET ".implode(",",$strsql)." WHERE noHP='".$record->sendnum."'";
- }
- }
- if(empty($sql))
- {
- $sql="INSERT INTO outbox(DestinationNumber, TextDecoded, DeliveryReport,CreatorID)
- VALUES('Maaf Format Salah Silahkan Coba Kembali','".$record->sendnum."','no','QuickCount')";
- }
- }
- else
- {
- $sql="INSERT INTO outbox(DestinationNumber, TextDecoded, DeliveryReport,CreatorID)
- VALUES('Maaf Nomor Anda Belum Terdaftar','".$record->sendernumber."','no','QuickCount')"
- }
- mysql_query($sql) or die(mysql_error());
- $sql="UPDATE inbox SET Processed='true' WHERE SenderNumber='".$record->sendernumber."' AND Processed='false'";
- mysql_query($sql) or die(mysql_error());
- }
- }
- echo "refresh complete";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement