Return to Snippet

Revision: 53243
at January 18, 2016 14:15 by fazlee


Updated Code
<?php
/* --------------------------------------------
	Malaysia Prayer time (e-Solat.gov.my)
	--------------------
	Data source : 	http://www.e-solat.com.my
	Author		: 	Fazlee Rezuan [[email protected]]
	version		: 	2.1
	Description : 	Sila tukar kod kawasan didalam value 'Kod Kawasan' atau 
					guna parameter seperti 'http://solat.dynamiclabs.my/JHR01'. 
					Pastikan ada file .htaccess di dalam direktori yang sama.

					.htaccess
					======== Start ==========
					RewriteEngine on
					RewriteBase /
					RewriteCond %{SCRIPT_FILENAME} !-d
					RewriteCond %{SCRIPT_FILENAME} !-f
					RewriteRule ^(.*)$ index.php?kod=$1 [QSA]
					========== End ========

 ----------------------------------- */

// Kod Kawasan
if($_GET['kod'] == ''){ $kod_kawasan = 'SGR01'; }
else { $kod_kawasan = $_GET['kod']; }

$area = array(
			'JHR01' => 'Pulau Aur dan Pemanggil',
			'JHR02' => 'Kota Tinggi, Mersing, Johor Bahru',
			'JHR03' => 'Kluang dan Pontian',
			'JHR04' => 'Batu Pahat, Muar, Segamat, Gemas',
			'KDH01' => 'Kota Setar, Kubang Pasu, Pokok Sena',
			'KDH02' => 'Pendang, Kuala Muda, Yan',
			'KDH03' => 'Padang Terap, Sik',
			'KDH04' => 'Baling',
			'KDH05' => 'Kulim, Bandar Bahru',
			'KDH06' => 'Langkawi',
			'KDH07' => 'Gunung Jerai',
			'KTN01' => 'K.Bharu,Bachok,Pasir Puteh,Tumpat,Pasir Mas,Tnh. Merah,Machang,Kuala Krai,Mukim Chiku',
			'KTN03' => 'Jeli, Gua Musang (Mukim Galas, Bertam)',
			'MLK01' => 'Bandar Melaka, Alor Gajah, Jasin, Masjid Tanah, Merlimau, Nyalas',
			'NGS01' => 'Jempol, Tampin',
			'NGS02' => 'Port Dickson, Seremban, Kuala Pilah, Jelebu, Rembau',
			'PHG01' => 'Pulau Tioman',
			'PHG02' => 'Kuantan, Pekan, Rompin, Muadzam Shah',
			'PHG03' => 'Maran, Chenor, Temerloh, Bera, Jerantut',
			'PHG04' => 'Bentong, Raub, Kuala Lipis',
			'PHG05' => 'Genting Sempah, Janda Baik, Bukit Tinggi',
			'PHG06' => 'Bukit Fraser, Genting Higlands, Cameron Higlands',
			'PLS01' => 'Kangar, Padang Besar, Arau',
			'PNG01' => 'Seluruh Negeri Pulau Pinang',
			'PRK01' => 'Tapah,Slim River dan Tanjung Malim',
			'PRK02' => 'Ipoh, Batu Gajah, Kampar, Sg. Siput dan Kuala Kangsar',
			'PRK03' => 'Pengkalan Hulu, Grik dan Lenggong',
			'PRK04' => 'Temengor dan Belum',
			'PRK05' => 'Teluk Intan, Bagan Datoh, Kg.Gajah,Sri Iskandar, Beruas,Parit,Lumut,Setiawan dan Pulau Pangkor',
			'PRK06' => 'Selama, Taiping, Bagan Serai dan Parit Buntar',
			'PRK07' => 'Bukit Larut',
			'SBH01' => 'Zon 1 - Sandakan, Bdr. Bkt. Garam, Semawang, Temanggong, Tambisan',
			'SBH02' => 'Zon 2 - Pinangah, Terusan, Beluran, Kuamut, Telupit',
			'SBH03' => 'Zon 3 - Lahad Datu, Kunak, Silabukan, Tungku, Sahabat, Semporna',
			'SBH04' => 'Zon 4 - Tawau, Balong, Merotai, Kalabakan',
			'SBH05' => 'Zon 5 - Kudat, Kota Marudu, Pitas, Pulau Banggi',
			'SBH06' => 'Zon 6 - Gunung Kinabalu',
			'SBH07' => 'Zon 7 - Papar, Ranau, Kota Belud, Tuaran, Penampang, Kota Kinabalu',
			'SBH08' => 'Zon 8 - Pensiangan, Keningau, Tambunan, Nabawan',
			'SBH09' => 'Zon 9 - Sipitang, Membakut, Beaufort, Kuala Penyu, Weston, Tenom, Long Pa Sia',
			'SGR01' => 'Gombak,H.Selangor,Rawang, H.Langat,Sepang,Petaling,  S.Alam',
			'SGR02' => 'Sabak Bernam, Kuala Selangor,  Klang, Kuala Langat',
			'SGR03' => 'Kuala Lumpur',
			'SGR04' => 'Putrajaya',
			'SWK01' => 'Zon 1 - Limbang, Sundar, Terusan, Lawas',
			'SWK02' => 'Zon 2 - Niah, Belaga, Sibuti, Miri, Bekenu, Marudi',
			'SWK03' => 'Zon 3 - Song, Belingan, Sebauh, Bintulu, Tatau, Kapit',
			'SWK04' => 'Zon 4 - Igan, Kanowit, Sibu, Dalat, Oya',
			'SWK05' => 'Zon 5 - Belawai, Matu, Daro, Sarikei, Julau, Bitangor, Rajang',
			'SWK06' => 'Zon 6 - Kabong, Lingga, Sri Aman, Engkelili, Betong, Spaoh, Pusa, Saratok, Roban, Debak',
			'SWK07' => 'Zon 7 - Samarahan, Simunjan, Serian, Sebuyau, Meludam',
			'SWK08' => 'Zon 8 - Kuching, Bau, Lundu,Sematan',
			'SWK09' => 'Zon 9 - Zon Khas',
			'TRG01' => 'Kuala Terengganu, Marang',
			'TRG02' => 'Besut, Setiu',
			'TRG03' => 'Hulu Terengganu',
			'TRG04' => 'Kemaman Dungun',
			'WLY02' => 'Labuan'
	);

if(!$area) { $area_title = $area[$kod_kawasan]; } else { $area_title = $area[$_GET['kod']]; }


$value = strip_tags(file_get_contents('http://www2.e-solat.gov.my/solat.php?kod='.$kod_kawasan.'&lang=BM'));


$stripped_value = preg_replace('/\s+/',' ',$value);
$waktu 			= explode('WaktuSolat', str_replace('&nbsp;', ' ', $stripped_value));
$waktu1 		= ereg_replace("[^0-9: ]", "", $waktu[1]);
$solat 			= explode(' ', str_replace('       ',' ', $waktu1));
$strip_waktu 	= explode(" ", $waktu[0]);

$waktu_solat = array(
				'Imsak' 	=> $strip_waktu[(array_search('Imsak', $strip_waktu)+1)],
				'Subuh' 	=> $strip_waktu[(array_search('Subuh', $strip_waktu)+1)],
				'Syuruk' 	=> $strip_waktu[(array_search('Syuruk', $strip_waktu)+1)],
				'Zohor' 	=> $strip_waktu[(array_search('Zohor', $strip_waktu)+1)],
				'Asar' 		=> $strip_waktu[(array_search('Asar', $strip_waktu)+1)],
				'Maghrib' 	=> $strip_waktu[(array_search('Maghrib', $strip_waktu)+1)],
				'Isyak' 	=> $strip_waktu[(array_search('Isyak', $strip_waktu)+1)]
			);

foreach ($waktu_solat as $nama_waktu => $jam_waktu) {
    $solat_time .= $nama_waktu.": ".@date('g:ia', @strtotime($jam_waktu)).", ";
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Watu Solat <?php echo $area_title; ?></title>
	<meta name="description" content="<?php echo $solat_time; ?>">
	<meta name="author" content="Fazlee Rezuan">
</head>
<body>
	<h3><?php echo $area_title; ?></h3>
	<h5><?php echo date('d M Y'); ?></h5>
	<?php 
foreach ($waktu_solat as $nama_waktu => $jam_waktu) {
    echo $nama_waktu.": ".@date('g:ia', @strtotime($jam_waktu))."<br> ";
}
	?>
</body>
</html>

Revision: 53242
at January 18, 2016 00:29 by fazlee


Updated Code
<?php
/* --------------------------------------------
	Malaysia Prayer time
	--------------------
	Data source : http://www.e-solat.com.my
	Author		: Fazlee Rezuan [[email protected]]
	version		: 2.0
	Description : Sila tukar kod kawasan didalam value 'Kod Kawasan'. 

	Kod kawasan(Mungkin berubah):

	== JOHOR ==
	JHR01 : Pulau Aur dan Pemanggil
	JHR02 : Kota Tinggi, Mersing, Johor Bahru
	JHR03 : Kluang dan Pontian
	JHR04 : Batu Pahat, Muar, Segamat, Gemas

	== Kedah ==
	KDH01 : Kota Setar, Kubang Pasu, Pokok Sena
	KDH02 : Pendang, Kuala Muda, Yan
	KDH03 : Padang Terap, Sik
	KDH04 : Baling
	KDH05 : Kulim, Bandar Bahru
	KDH06 : Langkawi
	KDH07 : Gunung Jerai

	== kelantan ==
	KTN01 : K.Bharu,Bachok,Pasir Puteh,Tumpat,Pasir Mas,Tnh. Merah,Machang,Kuala Krai,Mukim Chiku
	KTN03 : Jeli, Gua Musang (Mukim Galas, Bertam)

	== Melaka ==
	MLK01 : Bandar Melaka, Alor Gajah, Jasin, Masjid Tanah, Merlimau, Nyalas

	== Negeri Sembilan ==
	NGS01 : Jempol, Tampin
	NGS02 : Port Dickson, Seremban, Kuala Pilah, Jelebu, Rembau

	== Pahang ==
	PHG01 : Pulau Tioman
	PHG02 : Kuantan, Pekan, Rompin, Muadzam Shah
	PHG03 : Maran, Chenor, Temerloh, Bera, Jerantut
	PHG04 : Bentong, Raub, Kuala Lipis
	PHG05 : Genting Sempah, Janda Baik, Bukit Tinggi
	PHG06 : Bukit Fraser, Genting Higlands, Cameron Higlands

	== Perlis ==
	PLS01 : Kangar, Padang Besar, Arau

	== Pulau Pinang ==
	PNG01 : Seluruh Negeri Pulau Pinang

	== Perak ==
	PRK01 : Tapah,Slim River dan Tanjung Malim
	PRK02 : Ipoh, Batu Gajah, Kampar, Sg. Siput dan Kuala Kangsar
	PRK03 : Pengkalan Hulu, Grik dan Lenggong
	PRK04 : Temengor dan Belum
	PRK05 : Teluk Intan, Bagan Datoh, Kg.Gajah,Sri Iskandar, Beruas,Parit,Lumut,Setiawan dan Pulau Pangkor
	PRK06 : Selama, Taiping, Bagan Serai dan Parit Buntar
	PRK07 : Bukit Larut

	== Sabah == 
	SBH01 : Zon 1 - Sandakan, Bdr. Bkt. Garam, Semawang, Temanggong, Tambisan
	SBH02 : Zon 2 - Pinangah, Terusan, Beluran, Kuamut, Telupit
	SBH03 : Zon 3 - Lahad Datu, Kunak, Silabukan, Tungku, Sahabat, Semporna
	SBH04 : Zon 4 - Tawau, Balong, Merotai, Kalabakan
	SBH05 : Zon 5 - Kudat, Kota Marudu, Pitas, Pulau Banggi
	SBH06 : Zon 6 - Gunung Kinabalu
	SBH07 : Zon 7 - Papar, Ranau, Kota Belud, Tuaran, Penampang, Kota Kinabalu
	SBH08 : Zon 8 - Pensiangan, Keningau, Tambunan, Nabawan
	SBH09 : Zon 9 - Sipitang, Membakut, Beaufort, Kuala Penyu, Weston, Tenom, Long Pa Sia

	== Selangor ==
	SGR01 : Gombak,H.Selangor,Rawang, H.Langat,Sepang,Petaling,  S.Alam
	SGR02 : Sabak Bernam, Kuala Selangor,  Klang, Kuala Langat

	== Kuala Lumpur ==
	SGR03 : Kuala Lumpur

	== Putrajaya ==
	SGR04 : Putrajaya

	== Sarawak ==
	SWK01 : Zon 1 - Limbang, Sundar, Terusan, Lawas
	SWK02 : Zon 2 - Niah, Belaga, Sibuti, Miri, Bekenu, Marudi
	SWK03 : Zon 3 - Song, Belingan, Sebauh, Bintulu, Tatau, Kapit
	SWK04 : Zon 4 - Igan, Kanowit, Sibu, Dalat, Oya
	SWK05 : Zon 5 - Belawai, Matu, Daro, Sarikei, Julau, Bitangor, Rajang
	SWK06 : Zon 6 - Kabong, Lingga, Sri Aman, Engkelili, Betong, Spaoh, Pusa, Saratok, Roban, Debak
	SWK07 : Zon 7 - Samarahan, Simunjan, Serian, Sebuyau, Meludam
	SWK08 : Zon 8 - Kuching, Bau, Lundu,Sematan
	SWK09 : Zon 9 - Zon Khas

	== Terengganu ==
	TRG01 : Kuala Terengganu, Marang
	TRG02 : Besut, Setiu
	TRG03 : Hulu Terengganu
	TRG04 : Kemaman Dungun

	== Labuan ==
	WLY02 : Labuan

 ----------------------------------- */

// Kod Kawasan
$kod_kawasan = 'SGR01';


$value = strip_tags(file_get_contents('http://www2.e-solat.gov.my/solat.php?kod='.$kod_kawasan.'&lang=BM'));


$stripped_value = preg_replace('/\s+/',' ',$value);
$waktu 			= explode('WaktuSolat', str_replace('&nbsp;', ' ', $stripped_value));
$waktu1 		= ereg_replace("[^0-9: ]", "", $waktu[1]);
$solat 			= explode(' ', str_replace('       ',' ', $waktu1));
$strip_waktu 	= explode(" ", $waktu[0]);

$waktu_solat = array(
				'Imsak' 	=> $strip_waktu[(array_search('Imsak', $strip_waktu)+1)],
				'Subuh' 	=> $strip_waktu[(array_search('Subuh', $strip_waktu)+1)],
				'Syuruk' 	=> $strip_waktu[(array_search('Syuruk', $strip_waktu)+1)],
				'Zohor' 	=> $strip_waktu[(array_search('Zohor', $strip_waktu)+1)],
				'Asar' 		=> $strip_waktu[(array_search('Asar', $strip_waktu)+1)],
				'Maghrib' 	=> $strip_waktu[(array_search('Maghrib', $strip_waktu)+1)],
				'Isyak' 	=> $strip_waktu[(array_search('Isyak', $strip_waktu)+1)]
			);

foreach ($waktu_solat as $nama_waktu => $jam_waktu) {
    echo $nama_waktu." : ".@date('g:ia', @strtotime($jam_waktu))."\n";
}

?>

Revision: 53241
at February 2, 2014 01:43 by fazlee


Updated Code
<?php
/* --------------------------------------------
	Malaysia Prayer time for GeekTools
	Data source : http://www.e-solat.com.my
	Author		: Fazlee Rezuan [[email protected]]
	version		: 1.1
 ----------------------------------- */
// Get the page
$value = strip_tags(file_get_contents('http://www2.e-solat.gov.my/solat.php?kod=sgr01&lang=BM'));

// Remove unwanted strings & values, cleaning html tags and spaces
//$stripped_value = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $value);
$stripped_value = preg_replace('/\s+/',' ',$value);
$waktu 			= explode('WaktuSolat', str_replace('&nbsp;', ' ', $stripped_value));
$waktu1 		= ereg_replace("[^0-9: ]", "", $waktu[1]);
$solat 			= explode(' ', str_replace('       ',' ', $waktu1));
$strip_waktu 	= explode(" ", $waktu[0]);

// Print out prayer time
echo "Subuh:".@date('g:ia', @strtotime($strip_waktu[6]))."\tZuhur:".@date('g:ia', @strtotime($strip_waktu[10])).
		"\tAsar:".@date('g:ia', @strtotime($strip_waktu[12]))."\tMaghrib:".@date('g:ia', @strtotime($strip_waktu[14]))."\tIsyak:".@date('g:ia', @strtotime($strip_waktu[16]));
?>

Revision: 53240
at November 17, 2011 03:19 by fazlee


Initial Code
<?php
/* --------------------------------------------
	Malaysia Prayer time for GeekTools
	Data source : http://www.e-solat.com.my
	Author		: Fazlee Rezuan [[email protected]]
 ----------------------------------- */
// Get the page
$value = strip_tags(file_get_contents('http://www.e-solat.gov.my/solat.php?kod=sgr01&lang=BM'));

// Remove unwanted strings & values, cleaning html tags and spaces
$stripped_value = preg_replace('/\s+/','',$value);
$waktu 			= explode('WaktuSolat', str_replace('&nbsp;', ' ', $stripped_value));
$waktu1 		= ereg_replace("[^0-9: ]", "", $waktu[1]);
$solat 			= explode(' ', str_replace('       ',' ', $waktu1));

// Print out prayer time
echo "Subuh: ".@date('g:ia', @strtotime($solat[2]))."\t\tZuhur: ".@date('g:ia', @strtotime($solat[4])).
		"\t\tAsar: ".@date('g:ia', @strtotime($solat[5]))."\nMaghrib: ".@date('g:ia', @strtotime($solat[6]))."\t\tIsyak: ".@date('g:ia', @strtotime($solat[7]));

?>

Initial URL

                                

Initial Description
The purpose of this code is to grab information from e-solat.gov.my and get payer exact time.

Initial Title
e-solat php script

Initial Tags

                                

Initial Language
PHP