-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgempa.php
68 lines (61 loc) · 2.38 KB
/
gempa.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
error_reporting(0);
/*
@ Gempa - Info gempa from bmkg.go.id
@ This project was created by Dfv47 with Black Coder Crush.
@ Copyright 25 - 12 - 2k19 @m_d4fv
@ Thank's to Akin
*/
class Gempa
{
private $r = "\033[91m",
$g = "\033[92m",
$y = "\033[93m",
$b = "\033[94m",
$m = "\033[95m",
$c = "\033[96m",
$w = "\033[97m",
$n = "\033[0m",
$p = "\033[1;30m";
public function __construct()
{
$this->banner();
$this->printInfo();
}
// banner
public function banner()
{
echo "{$this->y} _____ {$this->r}{ {$this->p}PHP script {$this->r}} \n";
echo "{$this->y} | __|___ _____ ___ ___ {$this->w}Author {$this->r}: {$this->w}M Daffa \n";
echo "{$this->y} | | | -_| | . | .'| {$this->w}Team {$this->r}: {$this->w}Black Coder Crush \n";
echo "{$this->y} |_____|___|_|_|_| _|__,| {$this->w}Github {$this->r}: {$this->w}https://github.com/md4fv \n";
echo "{$this->y} |_| {$this->r}* {$this->p}Check info gempa from bmkg.go.id \n";
}
// get info gempa
private function printInfo()
{
$this->getInfo = file_get_contents("http://data.bmkg.go.id/lastgempadirasakan.xml");
// parse xml
$this->data = simplexml_load_string($this->getInfo) or die("error: cannot create object");
// save variable
$this->tanggal = $this->data->Gempa->Tanggal;
$this->jam = $this->data->Gempa->Jam;
$this->lintang = $this->data->Gempa->Lintang;
$this->bujur = $this->data->Gempa->Bujur;
$this->magnitude = $this->data->Gempa->Magnitude;
$this->kedalaman = $this->data->Gempa->Kedalaman;
$this->keterangan = $this->data->Gempa->Keterangan;
$this->dirasakan = $this->data->Gempa->Dirasakan;
// print info
echo " {$this->r}{ {$this->w}Gempa Information{$this->r} }\n";
echo " {$this->y}Tanggal {$this->r}:{$this->y} {$this->tanggal} \n";
echo " {$this->y}Jam {$this->r}:{$this->y} {$this->jam} \n";
echo " {$this->y}Lintang {$this->r}:{$this->y} {$this->lintang} \n";
echo " {$this->y}Bujur {$this->r}:{$this->y} {$this->bujur} \n";
echo " {$this->y}Magnitude {$this->r}:{$this->y} {$this->magnitude} \n";
echo " {$this->y}Kedalaman {$this->r}:{$this->y} {$this->kedalaman} \n";
echo " {$this->y}Keterangan {$this->r}:{$this->y} {$this->keterangan} \n";
echo " {$this->y}Dirasakan {$this->r}:{$this->y} {$this->dirasakan} \n";
}
}
$data = new Gempa();