Created
August 20, 2025 09:27
-
-
Save desawarna/b8a7a257b64647bc8433a4fa0619cd06 to your computer and use it in GitHub Desktop.
slimswa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('DB_HOST', 'localhost'); | |
define('DB_PORT', '3306'); | |
define('DB_NAME', 'plp_slms8'); | |
define('DB_USERNAME', 'plp_slms8'); | |
define('DB_PASSWORD', 'cS9pu1-b@4a'); | |
$conn = mysqli_connect(DB_HOST,DB_NAME,DB_PASSWORD,DB_USERNAME); | |
$data = json_decode(file_get_contents('php://input'), true); | |
$number = $data["from"]; | |
$message = $data["message"]; | |
$wa_no = $number; | |
$wa_text0 = $message; | |
$wa_text = strtoupper($message); | |
if ($wa_no . $wa_text == '') { exit ; } | |
$exp = explode(' ', $wa_text) ; | |
$text1 = $exp[0]; | |
$text2 = $exp[1]; | |
$text3 = $exp[2]; | |
if ($text1 == 'INFO') { | |
$msg = "_Assalamualaikum wr.wb._ | |
Selamat datang di *_chatbot_* Perpustakaan Universitas Muhammadiyah Palopo | |
Masukkan kata kunci untuk melakukan pencarian. | |
Pencarian berdasarkan *JUDUL* | |
Ketik : search title judul yang dibutuhkan | |
Contoh : *_search title sejarah_* | |
Pencarian berdasarkan *PENULIS* | |
Ketik : search author nama penulis | |
Contoh : *_search author andi_* | |
Pencarian berdasarkan *ISBN* | |
Ketik : search isbn kode isbn | |
Contoh : *_search isbn 0123456789_* | |
Pencarian berdasarkan *ISSN* | |
Ketik : search isbn kode issn | |
Contoh : *_search issn 0123456789_* | |
Terima kasih🙏🙏🙏"; | |
sendMessage($wa_no, $msg); | |
} | |
if ($text2 == 'TITLE') { | |
$result = (mysqli_query($conn,"SELECT * FROM biblio a left join biblio_author b on a.biblio_id=b.biblio_id left join mst_author c on b.author_id=c.author_id | |
WHERE `title` LIKE '%$text3%'")) or die (mysqli_error($result)); | |
if(mysqli_num_rows($result) > 0){ | |
while ($row=mysqli_fetch_array($result)){ | |
$msg .= 'Title: '.$row['title'].' | |
Author: '.$row['author_name'].' | |
ISBN/ISSN: '.$row['isbn_issn'].' | |
Year: '.$row['publish_year'].' | |
Callnumber: '.$row['call_number'].' | |
Detail: https://opacumpalopo.my.id/index.php?p=show_detail&id='.$row['biblio_id'].' | |
'; | |
} | |
} else { | |
$msg .= 'Mohon maaf Referensi yang anda inginkan belum tersedia. Silahkan masukkan kata kunci yang lain. Terima Kasih🙏'; | |
} | |
sendMessage($wa_no, $msg); | |
} | |
if ($text2 == 'AUTHOR') { | |
$result = (mysqli_query($conn,"SELECT * FROM biblio a left join biblio_author b on a.biblio_id=b.biblio_id left join mst_author c on b.author_id=c.author_id | |
WHERE author_name LIKE '%$text3%'")) or die (mysqli_error($result)); | |
if(mysqli_num_rows($result) > 0){ | |
while ($row=mysqli_fetch_array($result)){ | |
$msg .= 'Title: '.$row['title'].' | |
Author: '.$row['author_name'].' | |
ISBN/ISSN: '.$row['isbn_issn'].' | |
Year: '.$row['publish_year'].' | |
Callnumber: '.$row['call_number'].' | |
Detail: https://opacumpalopo.my.id/index.php?p=show_detail&id='.$row['biblio_id'].' | |
'; | |
} | |
} else { | |
$msg .= 'Mohon maaf Penulis yang anda inginkan belum tersedia. Silahkan masukkan penulis yang lain. Terima Kasih🙏'; | |
} | |
sendMessage($wa_no, $msg); | |
} | |
if ($text2 == 'ISBN') { | |
$result = (mysqli_query($conn,"SELECT * FROM biblio a left join biblio_author b on a.biblio_id=b.biblio_id left join mst_author c on b.author_id=c.author_id | |
WHERE isbn_issn LIKE '%$text3%'")) or die (mysqli_error($result)); | |
if(mysqli_num_rows($result) > 0){ | |
while ($row=mysqli_fetch_array($result)){ | |
$msg .= 'Title: '.$row['title'].' | |
Author: '.$row['author_name'].' | |
ISBN/ISSN: '.$row['isbn_issn'].' | |
Year: '.$row['publish_year'].' | |
Callnumber: '.$row['call_number'].' | |
Detail: https://opacumpalopo.my.id/index.php?p=show_detail&id='.$row['biblio_id'].' | |
'; | |
} | |
} else { | |
$msg .= 'Mohon maaf ISBN yang anda inginkan belum tersedia. Terima Kasih🙏'; | |
} | |
sendMessage($wa_no, $msg); | |
} | |
if ($text2 == 'ISSN') { | |
$result = (mysqli_query($conn,"SELECT * FROM biblio a left join biblio_author b on a.biblio_id=b.biblio_id left join mst_author c on b.author_id=c.author_id | |
WHERE isbn_issn LIKE '%$text3%'")) or die (mysqli_error($result)); | |
if(mysqli_num_rows($result) > 0){ | |
while ($row=mysqli_fetch_array($result)){ | |
$msg .= 'Title: '.$row['title'].' | |
Author: '.$row['author_name'].' | |
ISBN/ISSN: '.$row['isbn_issn'].' | |
Year: '.$row['publish_year'].' | |
Callnumber: '.$row['call_number'].' | |
Detail: https://opacumpalopo.my.id/index.php?p=show_detail&id='.$row['biblio_id'].' | |
'; | |
} | |
} else { | |
$msg .= 'Mohon maaf ISSN yang anda inginkan belum tersedia. Terima Kasih🙏'; | |
} | |
sendMessage($wa_no, $msg); | |
} | |
function sendMessage($wa_no, $wa_text) { | |
$url = 'https://dash.whacenter.id/api/send'; | |
$ch = curl_init($url); | |
$nohp= $wa_no; | |
$pesan= $wa_text; | |
$data = array( | |
'device_id' => '2880582723e52c441e6e540c1335c987', | |
'number' => $nohp, | |
'message' => $pesan, | |
//'file' => 'https://urlgamba-file' | |
//ef4aad445bf4aa91bf63c40f4a773d1a | |
); | |
$payload = $data; | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
//echo $result; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment