<html>
<head>
<meta http-equiv="refresh" content="60; url=<?php $_SERVER['PHP_SELF']; ?>">
</head>
<body>
<h1>SMS SERVER SEDANG BERJALAN (AUTO REFRESH DALAM 60 DETIK)....JANGAN TUTUP JENDELA INI JIKA ANDA MENGATIFKAN AUTOJAWAB VIA SMS DENDA TILANG</h1>
<?php
mysql_connect("localhost", "root", "benk");
mysql_select_db("cma");
$query = "SELECT * FROM inbox WHERE Processed = 'false'";
$hasil = mysql_query($query);
while ($data = mysql_fetch_array($hasil))
{
  $id = $data['ID'];
  $noPengirim = $data['SenderNumber'];
  $msg = strtoupper($data['TextDecoded']);
  $pecah = explode("#", $msg);
  if ($pecah[0] == "TILANG")
  {
     $nim = $pecah[1];
	 mysql_connect("localhost", "root", "benk");
mysql_select_db("cma_tilang");
$SQL = "(SELECT * FROM tilang_januari where t_nomor = '$nim') 
           UNION
           (SELECT * FROM tilang_februari where t_nomor = '$nim') 
           UNION
		    (SELECT * FROM tilang_maret where t_nomor = '$nim') 
           UNION
		   (SELECT * FROM tilang_april where t_nomor = '$nim') 
           UNION
		   (SELECT * FROM tilang_mei where t_nomor = '$nim') 
           UNION
		   (SELECT * FROM tilang_juni where t_nomor = '$nim') 
           UNION
		   (SELECT * FROM tilang_juli where t_nomor = '$nim') 
           UNION
		   (SELECT * FROM tilang_agustus where t_nomor = '$nim') 
           UNION
		   (SELECT * FROM tilang_september where t_nomor = '$nim') 
           UNION
		   (SELECT * FROM tilang_oktober where t_nomor = '$nim') 
           UNION
		   (SELECT * FROM tilang_nopember where t_nomor = '$nim') 
           UNION
           (SELECT * FROM tilang_desember where t_nomor = '$nim')";
		   
$hasil2 = mysql_query($SQL);
while ($row = mysql_fetch_array($hasil2)){
   if (mysql_num_rows($hasil2) == 0) $reply = "DENDA TILANG TIDAK DITEMUAKAN PASTIKAN FORMAT : TILANG#NOMORTILANG";
 else
 {
    $data2 = mysql_fetch_array($hasil2);
	$nomor = $row['t_nomor'];
	$briva = $row['t_nomorbriva'];
     $denda = $row['t_denda'];
	 $nama = $row['t_nama'];
	 $bp = $row['t_biayaperkara'];
     $reply = "NO ".$nomor." AN ".$nama." -".$denda." + B.PERKARA ".$bp." Briva:".$briva."";
	 print ('NO '.$nomor.' AN  '.$nama.' -'.$denda.' + B.PERKARA '.$bp.' + Briva:'.$briva.'');
	 
 mysql_connect("localhost", "root", "benk");
mysql_select_db("cma");
$id = $data['ID'];
 $query3 = "UPDATE inbox SET Processed = 'true' WHERE ID = '$id'";
  $hasil3 = mysql_query($query3);
  $query3 = "INSERT INTO outbox(DestinationNumber, TextDecoded, CreatorID) VALUES ('$noPengirim', '$reply', 'Gammu')";
  $hasil3 = mysql_query($query3);
  }
  }
}}
?>
</body>
</html>
