ak47suk1

esolat php cli client

Jun 23rd, 2013
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. if($argc != 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
  4.  
  5.  
  6.     echo "Usage: php $argv[0] <zone>"."\n";
  7.     echo "Example: php $argv[0] NGS02"."\n";
  8.  
  9.     $zones = array(
  10.     array( 'Zone' => 'JHR02', 'Negeri' => 'JOHOR' , 'Lokasi' => 'Kota Tinggi, Mersing, Johor Bahru' ),
  11.     array( 'Zone' => 'JHR04', 'Negeri' => 'JOHOR' , 'Lokasi' => 'Batu Pahat, Muar, Segamat, Gemas' ),
  12.     array( 'Zone' => 'JHR03', 'Negeri' => 'JOHOR' , 'Lokasi' => 'Kluang dan Pontian' ),
  13.     array( 'Zone' => 'JHR01', 'Negeri' => 'JOHOR' , 'Lokasi' => 'Pulau Aur dan Pemanggil' ),
  14.  
  15.     array( 'Zone' => 'KDH06', 'Negeri' => 'KEDAH' , 'Lokasi' => 'Puncak Gunung Jerai' ),
  16.     array( 'Zone' => 'KDH01', 'Negeri' => 'KEDAH' , 'Lokasi' => 'Kota Setar, Kubang Pasu, Pokok Sena' ),
  17.     array( 'Zone' => 'KDH05', 'Negeri' => 'KEDAH' , 'Lokasi' => 'Langkawi' ),
  18.     array( 'Zone' => 'KDH02', 'Negeri' => 'KEDAH' , 'Lokasi' => 'Pendang, Kuala Muda, Yan' ),
  19.     array( 'Zone' => 'KDH03', 'Negeri' => 'KEDAH' , 'Lokasi' => 'Padang Terap, Sik, Baling' ),
  20.     array( 'Zone' => 'KDH04', 'Negeri' => 'KEDAH' , 'Lokasi' => 'Kulim, Bandar Baharu' ),
  21.  
  22.     array( 'Zone' => 'KTN03', 'Negeri' => 'KELANTAN' , 'Lokasi' => 'Jeli, Gua Musang (Mukim Galas, Bertam)' ),
  23.     array( 'Zone' => 'KTN01', 'Negeri' => 'KELANTAN' , 'Lokasi' => 'K.Bharu,Bachok,Pasir Puteh,Tumpat,Pasir Mas,Tnh. Merah,Machang,Kuala Krai,Mukim Chiku' ),
  24.  
  25.     array( 'Zone' => 'MLK01', 'Negeri' => 'MELAKA' , 'Lokasi' => 'Bandar Melaka, Alor Gajah, Jasin, Masjid Tanah, Merlimau, Nyalas' ),
  26.  
  27.     array( 'Zone' => 'NGS02', 'Negeri' => 'NEGERI SEMBILAN' , 'Lokasi' => 'Port Dickson, Seremban, Kuala Pilah, Jelebu, Rembau' ),
  28.     array( 'Zone' => 'NGS01', 'Negeri' => 'NEGERI SEMBILAN' , 'Lokasi' => 'Jempol, Tampin' ),
  29.  
  30.     array( 'Zone' => 'PHG05', 'Negeri' => 'PAHANG' , 'Lokasi' => 'Genting Sempah, Janda Baik, Bukit Tinggi' ),
  31.     array( 'Zone' => 'PHG04', 'Negeri' => 'PAHANG' , 'Lokasi' => 'Bentong, Raub, Kuala Lipis' ),
  32.     array( 'Zone' => 'PHG03', 'Negeri' => 'PAHANG' , 'Lokasi' => 'Maran, Chenor, Temerloh, Bera, Jerantut' ),
  33.     array( 'Zone' => 'PHG06', 'Negeri' => 'PAHANG' , 'Lokasi' => 'Bukit Fraser, Genting Higlands, Cameron Higlands' ),
  34.     array( 'Zone' => 'PHG02', 'Negeri' => 'PAHANG' , 'Lokasi' => 'Kuantan, Pekan, Rompin, Muadzam Shah' ),
  35.     array( 'Zone' => 'PHG01', 'Negeri' => 'PAHANG' , 'Lokasi' => 'Pulau Tioman' ),
  36.  
  37.     array( 'Zone' => 'PRK07', 'Negeri' => 'PERAK' , 'Lokasi' => 'Bukit Larut' ),
  38.     array( 'Zone' => 'PRK02', 'Negeri' => 'PERAK' , 'Lokasi' => 'Ipoh, Batu Gajah, Kampar, Sg. Siput dan Kuala Kangsar' ),
  39.     array( 'Zone' => 'PRK01', 'Negeri' => 'PERAK' , 'Lokasi' => 'Tapah,Slim River dan Tanjung Malim' ),
  40.     array( 'Zone' => 'PRK03', 'Negeri' => 'PERAK' , 'Lokasi' => 'Pengkalan Hulu, Grik dan Lenggong ' ),
  41.     array( 'Zone' => 'PRK04', 'Negeri' => 'PERAK' , 'Lokasi' => 'Temengor dan Belum' ),
  42.     array( 'Zone' => 'PRK05', 'Negeri' => 'PERAK' , 'Lokasi' => 'Teluk Intan, Bagan Datoh, Kg.Gajah,Sri Iskandar, Beruas,Parit,Lumut,Setiawan dan Pulau Pangkor' ),
  43.     array( 'Zone' => 'PRK06', 'Negeri' => 'PERAK' , 'Lokasi' => 'Selama, Taiping, Bagan Serai dan Parit Buntar' ),
  44.  
  45.     array( 'Zone' => 'PLS01', 'Negeri' => 'PERLIS' , 'Lokasi' => 'Kangar, Padang Besar, Arau' ),
  46.     array( 'Zone' => 'PNG01', 'Negeri' => 'PULAU PINANG' , 'Lokasi' => 'Seluruh Negeri Pulau Pinang' ),
  47.  
  48.     array( 'Zone' => 'SBH09', 'Negeri' => 'SABAH' , 'Lokasi' => 'Zon 9 - Sipitang, Membakut, Beaufort, Kuala Penyu, Weston, Tenom, Long Pa Sia' ),
  49.     array( 'Zone' => 'SBH08', 'Negeri' => 'SABAH' , 'Lokasi' => 'Zon 8 - Pensiangan, Keningau, Tambunan, Nabawan' ),
  50.     array( 'Zone' => 'SBH07', 'Negeri' => 'SABAH' , 'Lokasi' => 'Zon 7 - Papar, Ranau, Kota Belud, Tuaran, Penampang, Kota Kinabalu' ),
  51.     array( 'Zone' => 'SBH06', 'Negeri' => 'SABAH' , 'Lokasi' => 'Zon 6 - Gunung Kinabalu' ),
  52.     array( 'Zone' => 'SBH05', 'Negeri' => 'SABAH' , 'Lokasi' => 'Zon 5 - Kudat, Kota Marudu, Pitas, Pulau Banggi' ),
  53.     array( 'Zone' => 'SBH03', 'Negeri' => 'SABAH' , 'Lokasi' => 'Zon 3 - Lahad Datu, Kunak, Silabukan, Tungku, Sahabat, Semporna' ),
  54.     array( 'Zone' => 'SBH02', 'Negeri' => 'SABAH' , 'Lokasi' => 'Zon 2 - Pinangah, Terusan, Beluran, Kuamut, Telupit' ),
  55.     array( 'Zone' => 'SBH01', 'Negeri' => 'SABAH' , 'Lokasi' => 'Zon 1 - Sandakan, Bdr. Bkt. Garam, Semawang, Temanggong, Tambisan' ),
  56.     array( 'Zone' => 'SBH04', 'Negeri' => 'SABAH' , 'Lokasi' => 'Zon 4 - Tawau, Balong, Merotai, Kalabakan' ),
  57.  
  58.     array( 'Zone' => 'SWK01', 'Negeri' => 'SARAWAK' , 'Lokasi' => 'Zon 1 - Limbang, Sundar, Terusan, Lawas' ),
  59.     array( 'Zone' => 'SWK08', 'Negeri' => 'SARAWAK' , 'Lokasi' => 'Zon 8 - Kuching, Bau, Lundu,Sematan' ),
  60.     array( 'Zone' => 'SWK07', 'Negeri' => 'SARAWAK' , 'Lokasi' => 'Zon 7 - Samarahan, Simunjan, Serian, Sebuyau, Meludam' ),
  61.     array( 'Zone' => 'SWK06', 'Negeri' => 'SARAWAK' , 'Lokasi' => 'Zon 6 - Kabong, Lingga, Sri Aman, Engkelili, Betong, Spaoh, Pusa, Saratok, Roban, Debak' ),
  62.     array( 'Zone' => 'SWK05', 'Negeri' => 'SARAWAK' , 'Lokasi' => 'Zon 5 - Belawai, Matu, Daro, Sarikei, Julau, Bitangor, Rajang' ),
  63.     array( 'Zone' => 'SWK04', 'Negeri' => 'SARAWAK' , 'Lokasi' => 'Zon 4 - Igan, Kanowit, Sibu, Dalat, Oya' ),
  64.     array( 'Zone' => 'SWK03', 'Negeri' => 'SARAWAK' , 'Lokasi' => 'Zon 3 - Song, Belingan, Sebauh, Bintulu, Tatau, Kapit' ),
  65.     array( 'Zone' => 'SWK02', 'Negeri' => 'SARAWAK' , 'Lokasi' => 'Zon 2 - Niah, Belaga, Sibuti, Miri, Bekenu, Marudi' ),
  66.  
  67.     array( 'Zone' => 'SGR01', 'Negeri' => 'SELANGOR DAN WILAYAH PERSEKUTUAN' , 'Lokasi' => 'Gombak,H.Selangor,Rawang,H.Langat,Sepang,Petaling,S.Alam' ),
  68.     array( 'Zone' => 'SGR02', 'Negeri' => 'SELANGOR DAN WILAYAH PERSEKUTUAN' , 'Lokasi' => 'Sabak Bernam, Kuala Selangor, Klang, Kuala Langat' ),
  69.     array( 'Zone' => 'SGR03', 'Negeri' => 'SELANGOR DAN WILAYAH PERSEKUTUAN' , 'Lokasi' => 'Kuala Lumpur' ),
  70.     array( 'Zone' => 'SGR04', 'Negeri' => 'SELANGOR DAN WILAYAH PERSEKUTUAN' , 'Lokasi' => 'Putrajaya' ),
  71.  
  72.     array( 'Zone' => 'TRG01', 'Negeri' => 'TERENGGANU' , 'Lokasi' => 'Kuala Terengganu, Marang' ),
  73.     array( 'Zone' => 'TRG04', 'Negeri' => 'TERENGGANU' , 'Lokasi' => 'Kemaman Dungun' ),
  74.     array( 'Zone' => 'TRG03', 'Negeri' => 'TERENGGANU' , 'Lokasi' => 'Hulu Terengganu' ),
  75.     array( 'Zone' => 'TRG02', 'Negeri' => 'TERENGGANU' , 'Lokasi' => 'Besut, Setiu' ),
  76.  
  77.     array( 'Zone' => 'WLY02', 'Negeri' => 'WILAYAH PERSEKUTUAN LABUAN' , 'Lokasi' => 'Labuan' )
  78.  
  79. );
  80.  
  81.  
  82. }
  83.  
  84. else
  85.  
  86. {
  87.     $content = file_get_contents("http://www.e-solat.gov.my/web/xml/today/?zon=$argv[1]");
  88.     $x = new SimpleXmlElement($content);
  89.     echo $x->channel->title[0]."\n";
  90.     echo $x->channel->description[0]."\n";
  91.     foreach($x->channel->item as $entry) {
  92.         echo $entry->title.' '.$entry->description."\n";
  93.     }
  94. }
  95. ?>
RAW Paste Data