Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // mengecek apakah sebuah nomor hp sudah teregistrasi atau belum
- function ceknohp($nohp)
- {
- $query = "SELECT * FROM mahasiswa WHERE telepon = '$nohp'";
- $hasil = mysql_query($query);
- if (mysql_num_rows($hasil) > 0) return 1;
- else return 0;
- }
- // cek kesesuaian nomor hp dan pin
- function cekpin($nohp, $pin)
- {
- $query = "SELECT * FROM mahasiswa WHERE telepon = '$nohp'";
- $hasil = mysql_query($query);
- $data = mysql_fetch_array($hasil);
- if ($pin == $data['pin']) return 1;
- else return 0;
- }
- // baca nilai matakuliah berdasarkan kode mk dan no hp si mahasiswa
- function bacanilai($nohp, $kodemk)
- {
- $query = "SELECT c.nm_mtk, CASE b.nilai "
- ."WHEN '4' THEN 'A' "
- ."WHEN '3' THEN 'B' "
- ."WHEN '2' THEN 'C' "
- ."WHEN '1' THEN 'D' "
- ."ELSE 'E' END AS grade "
- ."FROM mahasiswa a "
- ."LEFT JOIN nilai b USING(id_nim) "
- ."LEFT JOIN matakuliah c USING(id_mtk) "
- ."WHERE a.telepon = '$nohp' "
- ."AND c.kd_mtk = '$kodemk'";
- $hasil = mysql_query($query);
- if (mysql_num_rows($hasil) > 0)
- {
- $data = mysql_fetch_array($hasil);
- return "Nilai ".$data['nm_mtk']." Anda : ".$data['grade'];
- }
- else return "Matakuliah tidak ditemukan";
- }
- function bacajadwal($kodekls, $kodemk)
- {
- $query ="SELECT b.nm_mtk,d.hari,a.jam_mulai,a.jam_selesai "
- ."FROM jadwal a "
- ."LEFT JOIN matakuliah b USING(id_mtk) "
- ."LEFT JOIN kelas c USING(id_kelas) "
- ."LEFT JOIN hari d USING(id_hari) "
- ."WHERE b.kd_mtk='$kodemk' "
- ."AND c.kd_kelas='$kodekls' ";
- $hasil = mysql_query($query);
- if (mysql_num_rows($hasil) > 0)
- {
- $data = mysql_fetch_array($hasil);
- return "Jadwal ".$data['nm_mtk']." Hari : ".$data['hari']
- ." Waktu : ".$data['jam_mulai']."s.d.".$data['jam_selesai'];
- }
- else
- {
- return "Matakuliah tidak ditemukan";
- }
- }
- // baca nilai matakuliah per semester berdasarkan no hp si mahasiswa
- function nilai_per_semester($nohp, $smt)
- {
- $query = "SELECT c.nm_mtk, CASE b.nilai "
- ."WHEN '4' THEN 'A' "
- ."WHEN '3' THEN 'B' "
- ."WHEN '2' THEN 'C' "
- ."WHEN '1' THEN 'D' "
- ."ELSE 'E' END AS grade, "
- ."b.nilai,c.sks "
- ."FROM mahasiswa a "
- ."LEFT JOIN nilai b USING(id_nim) "
- ."LEFT JOIN matakuliah c USING(id_mtk) "
- ."WHERE a.telepon = '$nohp' "
- ."AND c.semester = '$smt'";
- $hasil = mysql_query($query);
- if (mysql_num_rows($hasil) > 0)
- {
- $nilai=$sks=0;
- $msg="DAFTAR NILAI SESMETER $smt\n";
- while($data = mysql_fetch_array($hasil)){
- $nilai+=$data['nilai']*$data['sks'];
- $sks+=$data['sks'];
- $msg.="Nilai ".$data['nm_mtk'].":".$data['grade']."\n";
- }
- return $msg."Nilai IPK semester $smt:".round($nilai/$sks,2);
- }
- else return "Nilai tidak ditemukan";
- }
- //baca jadwal perkelas berdasarkan kode kelas,thn Akademik "Y"
- function jadwal_per_kelas($kodekls)
- {
- $query ="SELECT c.nm_kelas,b.nm_mtk,d.hari,a.jam_mulai,a.jam_selesai "
- ."FROM jadwal a "
- ."LEFT JOIN thnakademik e USING(id_thn) "
- ."LEFT JOIN matakuliah b USING(id_mtk) "
- ."LEFT JOIN kelas c USING(id_kelas) "
- ."LEFT JOIN hari d USING(id_hari) "
- ."WHERE c.kd_kelas='$kodekls' "
- ."AND c.aktif='Y' "
- ."AND e.aktif='Y' ";
- $hasil = mysql_query($query);
- print_r($query);
- if (mysql_num_rows($hasil) > 0)
- {
- $msg="";
- while($data = mysql_fetch_array($hasil)){
- $msg.=($msg=="")?"DAFTAR JADWAL KELAS ".$data['nm_kelas']."\n":'';
- $msg.=$data['nm_mtk']." Hari : ".$data['hari']
- ." Waktu : ".$data['jam_mulai']." s.d ".$data['jam_selesai']."\n";
- }
- return $msg;
- }
- else return "Jadwal tidak ditemukan";
- }
- // kirim sms
- function sendsms($nohp, $pesan, $modem)
- {
- $pesan = str_replace("'", "\'", $pesan);
- if (strlen($pesan)<=160)
- {
- $query = "INSERT INTO outbox (DestinationNumber, TextDecoded, SenderID, CreatorID)
- VALUES ('$nohp', '$pesan', '$modem', 'Gammu')";
- $hasil = mysql_query($query);
- }
- else
- {
- $jmlSMS = ceil(strlen($pesan)/153);
- $pecah = str_split($pesan, 153);
- $query = "SHOW TABLE STATUS LIKE 'outbox'";
- $hasil = mysql_query($query);
- $data = mysql_fetch_array($hasil);
- $newID = $data['Auto_increment'];
- $random = rand(1, 255);
- $headerUDH = sprintf("%02s", strtoupper(dechex($random)));
- for ($i=1; $i<=$jmlSMS; $i++)
- {
- $udh = "050003".$headerUDH.sprintf("%02s", $jmlSMS).sprintf("%02s", $i);
- $msg = $pecah[$i-1];
- if ($i == 1)
- {
- $query = "INSERT INTO outbox (DestinationNumber, UDH, TextDecoded, ID, MultiPart, SenderID, CreatorID)
- VALUES ('$nohp', '$udh', '$msg', '$newID', 'true', '$modem', 'Gammu')";
- }
- else $query = "INSERT INTO outbox_multipart(UDH, TextDecoded, ID, SequencePosition)
- VALUES ('$udh', '$msg', '$newID', '$i')";
- echo $query;die();
- mysql_query($query);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement