Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
- <meta http-equiv='refresh' content='2; url=sms.php'>
- <meta name="author" content="C4Hy4"/>
- <meta name="updater" content="C4Hy4"/>
- <title>SMS Autoresponse</title>
- <style type="text/css">
- @import url(http://fonts.googleapis.com/css?family=Share);
- body {
- background: #fff;
- font-family : 'Share',Arial, Helvetica, sans-serif;
- margin:50px 0px; padding:0px;
- text-align:center;
- }
- .container {
- width:390px;
- margin:0px auto;
- text-align:left;
- padding:15px;
- margin-top:5px;
- margin-bottom:5px;
- border:1px solid #D9E2E9;
- -webkit-border-radius: 8px;
- -moz-border-radius: 8px;
- border-radius: 8px;
- //border:1px dashed #333;
- }
- .format_list {
- width:390px;
- margin:0px auto;
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;
- border-radius: 5px;
- }
- </style>
- </head>
- <body>
- <div id="container">
- <h1> SMS FORMAT: </h1>
- <fieldset class="format_list">
- <legend><h2>Nilai per Semester</h2></legend>
- <div class="format_sms">
- <div>format: N#NIM#SEMESTER </div>
- <div>contoh: N#201201#I </div>
- </div>
- </fieldset>
- <fieldset class="format_list">
- <legend><h2>Nilai IPK</h2></legend>
- <div class="format_sms">
- <div>format: I#NIM</div>
- <div>contoh: I#201201</div>
- </div>
- </fieldset>
- <fieldset class="format_list">
- <legend><h2>Bantuan</h2></legend>
- <div class="format_sms">
- <div>format: H#NIM</div>
- <div>contoh: H#201201</div>
- </div>
- </fieldset>
- </div>
- <?php
- //koneksi ke database
- mysql_connect("localhost","root","root");
- mysql_select_db("smsd");
- //fungsi pengiriman SMS/memasukkan data ke table outbox
- function send_sms($no,$pesan){
- $masuk = mysql_query(
- "INSERT INTO outbox "
- ."(InsertIntoDB,SendingDateTime,DestinationNumber,TextDecoded,SendingTimeOut,DeliveryReport,CreatorID)"
- ." VALUES (sysdate(),sysdate(),'".$no."','".$pesan."',sysdate(),'yes','system')"
- );
- return $masuk;
- }
- //cek sms masuk
- $sql = mysql_query("SELECT ID,TextDecoded,SenderNumber FROM inbox WHERE Processed='false'");
- while ($data = mysql_fetch_object($sql)) {
- $keyword = strtoupper($data->TextDecoded);
- $explode = explode("#",trim($keyword));
- $param1 = isset($explode[2])?$explode[2]:'';
- $nim = $explode[1];
- $code= $explode[0];
- $cek_hp = mysql_query("SELECT hp FROM mahasiswa WHERE hp='".$data->SenderNumber."' AND nim='".$nim."'");
- $cari = mysql_num_rows($cek_hp);
- $pesan='';
- if ($cari == 0) {
- $pesan = "No Anda tidak terdaftar, daftarkan nomor handphone Anda ke bagian Administrator Sistem "
- ."untuk mendapatkan informasi nilai melalui SMS.";
- $masuk = send_sms($data->SenderNumber,$pesan);
- }else {
- // Nilai per semester
- if($code=='N' && $param1!=''){
- $qry="SELECT m.makul_singkat, n.nilai "
- ."FROM nilai n, makul m "
- ."WHERE m.semester='".$param1."' "
- ." AND n.nim='".$nim."' "
- ." AND n.kd_makul=m.kd_makul "
- ." AND n.semester=m.semester";
- $record_nilai = mysql_query($qry);
- $ketemu = mysql_num_rows($record_nilai);
- if ($ketemu == 0) {
- $pesan = "Nilai yang Anda minta belum ada / Keyword Anda salah.";
- $masuk = send_sms($data->SenderNumber,$pesan);
- } else {
- while ($hasil = mysql_fetch_object($record_nilai)){
- $pesan.=$hasil->makul_singkat.":".$hasil->nilai."\n";
- }
- $masuk = send_sms($data->SenderNumber,$pesan);
- }
- // Nilai IPK
- }elseif($code=="I"){
- $qry="SELECT m.sks,n.nilai "
- ."FROM nilai n, makul m "
- ."WHERE n.kd_makul = m.kd_makul "
- ." AND n.nim = '".$nim."'";
- $record_ipk=mysql_query($qry);
- $ketemu = mysql_num_rows($record_ipk);
- if ($ketemu == 0) {
- $pesan = "Nilai yang Anda minta belum ada / Keyword Anda salah.";
- $masuk = send_sms($data->SenderNumber,$pesan);
- }else{
- $tot_sks=0;
- $tot_nilai=0;
- while ($hasil = mysql_fetch_object($record_ipk)){
- $tot_sks+=$hasil->sks;
- $tot_nilai+=$hasil->sks*$hasil->nilai;
- }
- $ipk=$tot_nilai/$tot_sks;
- $pesan = "NIM : ".$nim.", IPK : ".$ipk;
- $masuk = send_sms($data->SenderNumber,$pesan);
- }
- }elseif($code=="H"){
- $pesan = "format sms, nilai : N#NIM#SEMESTER , IPK : I#NIM , Bantuan : H#NIM ";
- $masuk = send_sms($data->SenderNumber,$pesan);
- }else{
- $pesan = "Keyword Anda salah/ perintah tidak tersedia";
- $masuk = send_sms($data->SenderNumber,$pesan);
- }
- }
- if ($masuk) {
- //pilih mau diubah atau dihapus dari tabel, bila data sudah diproses
- //$ubah = mysql_query("UPDATE inbox SET Processed='true' WHERE ID='".$data->ID."'");
- mysql_query("DELETE FROM inbox WHERE ID='".$data->ID."'");
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement