Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
- <meta http-equiv='refresh' content='5; 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;
- font-family : 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>INFORMASI KRS</h2></legend>
- <div class="format_sms">
- <div>format: NIM#KRS </div>
- <div>contoh: 200922436#KRS </div>
- </div>
- </fieldset>
- <fieldset class="format_list">
- <legend><h2>INFORMASI KRU</h2></legend>
- <div class="format_sms">
- <div>format: NIM#KRU</div>
- <div>contoh: 200922436#KRU</div>
- </div>
- </fieldset>
- <fieldset class="format_list">
- <legend><h2>INFORMASI AKADEMIK</h2></legend>
- <div class="format_sms">
- <div>format: NIM#AKADEMIK</div>
- <div>contoh: 200922436#AKADEMIK</div>
- </div>
- </fieldset>
- </div>
- <?php
- //database configuration
- $dbhost="localhost";
- $dbuser="root";
- $dbpass="root";
- $dbname="dbsms";
- //database connection
- $db=new mysqli($dbhost,$dbuser,$dbpass,$dbname);
- //fungsi pengiriman SMS/memasukkan data ke table outbox
- function send_sms($db,$no,$pesan){
- $masuk = $db->query(
- "INSERT INTO outbox "
- ."(InsertIntoDB,SendingDateTime,DestinationNumber,TextDecoded,SendingTimeOut,DeliveryReport,CreatorID)"
- ." VALUES (sysdate(),sysdate(),'".$no."','".$pesan."',sysdate(),'yes','system')"
- );
- return $masuk;
- }
- //cek sms masuk
- $result = $db->query("SELECT ID,TextDecoded,SenderNumber FROM inbox WHERE Processed='false'");
- while ($data = $result->fetch_object()) {
- $keyword = strtoupper($data->TextDecoded);
- $explode = explode("#",trim($keyword));
- $nim = $explode[0];
- $code= $explode[1];
- $queryhp="SELECT IF(SUBSTR(TRIM(hp),1,1)='0',CONCAT('+62',SUBSTR(TRIM(hp),2)),TRIM(hp)) AS nohp "
- ."FROM mahasiswa "
- ."WHERE nim='".$nim."' "
- ."HAVING nohp='".$data->SenderNumber."'";
- if ($cek_hp = $db->query($queryhp)){
- if($cek_hp->num_rows>0){
- // INFO KRS
- if($code=='KRS')
- {
- $qry="SELECT pesan "
- ."FROM KRS "
- ."ORDER BY SendingDateTime DESC LIMIT 1";
- if($record_krs = $db->query($qry))
- {
- $hasil = $record_krs->fetch_object();
- $pesan =$hasil->pesan."\n";
- $masuk = send_sms($db,$data->SenderNumber,$pesan);
- $record_krs->close();
- }
- else
- {
- $pesan = "Info KRS yang Anda minta belum ada";
- $masuk = send_sms($db,$data->SenderNumber,$pesan);
- }
- }
- // INFO KRU
- elseif($code=='KRU')
- {
- $qry="SELECT pesan "
- ."FROM KRU "
- ."ORDER BY SendingDateTime DESC LIMIT 1";
- if ($record_kru = $db->query($qry))
- {
- $hasil = $record_kru->fetch_object();
- $pesan =$hasil->pesan."\n";
- $masuk = send_sms($db,$data->SenderNumber,$pesan);
- $record_kru->close();
- }
- else
- {
- $pesan = "Info KRU yang Anda minta belum ada";
- $masuk = send_sms($db,$data->SenderNumber,$pesan);
- }
- }
- // INFO AKADEMIK
- elseif($code=='AKADEMIK')
- {
- $qry="SELECT pesan "
- ."FROM AKADEMIK "
- ."ORDER BY SendingDateTime DESC LIMIT 1";
- if ($record_akademik = $db->query($qry))
- {
- $hasil = $record_akademik->fetch_object();
- $pesan = $hasil->pesan."\n";
- $masuk = send_sms($db,$data->SenderNumber,$pesan);
- $record_akademik->close();
- }
- else
- {
- $pesan = "Info AKADEMIK yang Anda minta belum ada";
- $masuk = send_sms($db,$data->SenderNumber,$pesan);
- }
- }
- // INFO BANTUAN
- elseif($code=="INFO")
- {
- $pesan = "format sms, KRS : NIM#KRS , KRU : NIM#KRU , AKADEMIK : NIM#AKADEMIK, Bantuan : NIM#INFO ";
- $masuk = send_sms($db,$data->SenderNumber,$pesan);
- }
- else
- {
- $pesan = "Keyword Anda salah/ perintah tidak tersedia";
- $masuk = send_sms($db,$data->SenderNumber,$pesan);
- }
- }else{
- $pesan = "No Anda tidak terdaftar, daftarkan nomor handphone Anda ke bagian Administrator Sistem "
- ."untuk mendapatkan informasi nilai melalui SMS.";
- $masuk = send_sms($db,$data->SenderNumber,$pesan);
- }
- }
- if ($masuk) {
- //pilih mau diubah atau dihapus dari tabel, bila data sudah diproses
- //$ubah = $db->query("UPDATE inbox SET Processed='true' WHERE ID='".$data->ID."'");
- $db->query("DELETE FROM inbox WHERE ID='".$data->ID."'");
- }
- }
- $db->close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement