Kenapa harus memberikan notifikasi suara ? ini untuk memudahkan kita dalam mengetahui apabila ada sms yang masuk. Tidak mungkin kita selalu memantau layar monitor komputer kita.
Pertama buat script seperti dibawah ini dan save dengan nama index.php. Script ini digunakan untuk memanggil script yang digunakan untuk mengecek sms masuk.
This file contains 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
halaman ini digunakan untuk melakukan pengecekan secara berkala SMS Baru yang masuk dengan interval 10 s | |
<br> | |
<br> | |
<table id="ok"> | |
</table><br> | |
<br> | |
<script type="text/javascript"> | |
function Ajax() | |
{ | |
var | |
$http, | |
$self = arguments.callee; | |
if (window.XMLHttpRequest) { | |
$http = new XMLHttpRequest(); | |
} else if (window.ActiveXObject) { | |
try { | |
$http = new ActiveXObject('Msxml2.XMLHTTP'); | |
} catch(e) { | |
$http = new ActiveXObject('Microsoft.XMLHTTP'); | |
} | |
} | |
if ($http) { | |
$http.onreadystatechange = function() | |
{ | |
if (/4|^complete$/.test($http.readyState)) { | |
document.getElementById('ok').innerHTML = $http.responseText; | |
setTimeout(function(){$self();}, 10000); | |
} | |
}; | |
$http.open('GET', 'auto_sound.php' + '?' + new Date().getTime(), true); | |
$http.send(null); | |
} | |
} | |
</script> | |
<script type="text/javascript"> | |
setTimeout(function() {Ajax();}, 10000); | |
</script> |
Kemudian buat script seperti dibawah ini dan namakan auto_sound.php
This file contains 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
<style type="text/css"> | |
#bro { | |
position:absolute; | |
left:10px; | |
top:375px; | |
width:0px; | |
height:0; | |
z-index:1; | |
overflow: hidden; | |
} | |
.isi { | |
font-family: verdana; | |
font-size: 11px; | |
text-decoration: none; | |
color: #000000; | |
} | |
.hp { | |
font-family: arial; | |
font-size: 11px; | |
color: #000000; | |
} | |
.style1 { | |
color: #0066FF; | |
font-weight: bold; | |
line-height: 18px; | |
} | |
.close { font-family: verdana; | |
font-size: 9px; | |
text-decoration: none; | |
color: #000000; | |
text-align: right; | |
} | |
#examplediv { | |
border-radius: 8px; | |
border: 1px solid #BCEBE9; | |
} | |
--> | |
</style> | |
<?php | |
// koneksi ke database. Sesuaikan dengan database gammu anda | |
$db = mysql_connect("localhost", "root", "root"); | |
mysql_select_db('smsbanking', $db); | |
// Ambil data dari tabel inbox dimana nilai kolom processed = false dan tampilkan 2 saja | |
$inbox=mysql_query("select * from inbox where Processed='false' limit 2"); | |
$jinbox=mysql_num_rows($inbox); | |
// jika data ada maka jalankan process ini | |
if ($jinbox>='1') | |
{ | |
?> | |
<div id="examplediv" style="width:250px; padding: 5px; background: #E3EFF2"><a class="isi"><span class="style1"> | |
<?php | |
echo"Pesan baru masuk</span><br />"; | |
while($tinbox=mysql_fetch_array($inbox)) | |
{ | |
echo "<a class='hp'><b>$tinbox[SenderNumber]</b> $tinbox[TextDecoded]</a><p>"; | |
// Update data tabel processed menjadi true agar ditandai sudah ditampilkan | |
$up=mysql_query("update inbox set Processed='true' where ID='$tinbox[ID]'"); | |
} | |
?> | |
<div id="bro"> | |
<audio controls="controls" autoplay="autoplay"> | |
<source src="sound.mp3" type="audio/mpeg" /> | |
<embed src="sound.mp3" /> | |
</audio> | |
</div> | |
<?php | |
} | |
?> | |
</a></div> |
Script diatas digunakan untuk menampilkan sms berikut notifikasi suara.
Download script diatas disini
Komentar