Advertisement
cdsatrian

quickcount sms

Aug 21st, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. <?php
  2. //--- Proses SMS
  3. $sql="SELECT COUNT(1) AS num
  4.      FROM dacal";
  5. $result=mysql_query($sql) or die(mysql_error());
  6. $cal=mysql_fetch_object($result);
  7. mysql_free_result($result);
  8. $sql="SELECT a.id,a.sendernumber,b.noHP AS sendnum, a.textdecoded
  9.      FROM inbox a
  10.      LEFT JOIN tps b ON b.noHP=REPLACE(a.sendernumber,'+62','0')
  11.      WHERE a.processed='false'";
  12. $result=mysql_query($sql);
  13. if(mysql_num_rows($result)>0)
  14. {
  15.   while($record=mysql_fetch_object($result))
  16.   {
  17.     if(!empty($record->sendnum))
  18.     {
  19.       $sms=explode(" ", $record->textdecoded);
  20.       $sql='';
  21.       if($sms[0]=='QC')
  22.       {
  23.         $strsql=array();
  24.         $kondisi=true;
  25.         for($i=1;$i<=$cal->num;$i++)
  26.         {
  27.           $kondisi= $kondisi && (is_numeric($sms[$i])?((int)$sms[$i]<0?false:true):false);
  28.           $strsql[]="calon".$i."='".$sms[$i]."' ";
  29.         }
  30.         if($kondisi){
  31.           $sql="UPDATE tps SET ".implode(",",$strsql)." WHERE noHP='".$record->sendnum."'";
  32.         }
  33.       }
  34.       if(empty($sql))
  35.       {
  36.         $sql="INSERT INTO outbox(DestinationNumber, TextDecoded, DeliveryReport,CreatorID)
  37.              VALUES('Maaf Format Salah Silahkan Coba Kembali','".$record->sendnum."','no','QuickCount')";
  38.       }
  39.     }
  40.     else
  41.     {
  42.       $sql="INSERT INTO outbox(DestinationNumber, TextDecoded, DeliveryReport,CreatorID)
  43.            VALUES('Maaf Nomor Anda Belum Terdaftar','".$record->sendernumber."','no','QuickCount')"
  44.     }
  45.     mysql_query($sql) or die(mysql_error());
  46.     $sql="UPDATE inbox SET Processed='true' WHERE SenderNumber='".$record->sendernumber."' AND Processed='false'";
  47.     mysql_query($sql) or die(mysql_error());
  48.   }
  49. }
  50. echo "refresh complete";
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement