-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
176 lines (153 loc) · 5.72 KB
/
index.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
require "rover.php";
$Mars = new HelloMars();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Pesquise as Fotos de Marte</title>
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Google Fonts -->
<link href='https://fonts.googleapis.com/css?family=Ubuntu:400,500,700,300,300italic,400italic,500italic,700italic' rel='stylesheet' type='text/css'>
</head>
<body>
<a href="https://github.com/joelgarciajr84/nasa-mars-pictures"><img style="position: absolute; top: 0; left: 0; border: 0;" src="images/fork-me.png" alt="Fork me on GitHub" data-canonical-src="images/fork-me.png"></a>
<div class="row row-header" id="top">
<div class="container">
<?php
if( !$Mars->CheckConnection() ):
echo "<p align='center' class='red'></p>";
else:
echo "<p align='center' class='green'></p>";
endif;
if(isset($_POST['data_das_fotos']) && isset($_POST['select_rover'])){
$photosdate = $_POST['data_das_fotos'];
$rover = $_POST['select_rover'];
$images = json_decode($Mars->getPictures($photosdate, $rover));
}
?>
<div class="col-lg-6 welcome">
<h1>Welcome to Mars</h1>
<hr>
<p>
Junte-se a nós na exploração a Marte. <br> Selecione ao lado o dia e qual sonda <br> espacial você deseja e visualize as fotos.
</p>
</div>
<div class="box-api">
<div align="center">
<img align="center" src="logo.png" alt="" style=" width: 25%;">
<img align="center" src="univale.jpg" alt="" style=" width: 25%;">
<hr>
</div>
<div align="center">
<form method="post" action="#resultado" >
<fieldset>
<!-- Form Name -->
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="Data">Data das Fotos</label>
<div class="col-md-5">
<input id="Data" name="data_das_fotos" type="date" value="<?php echo $photosdate; ?>"class="form-control input-md" required>
</div>
</div>
<br>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="select_rover">Selecione o Robô</label>
<div class="col-md-4">
<select required id="select_rover" name="select_rover" class="form-control">
<option value="">Selecione</option>
<?php
if(is_array($Mars->rovers)):
foreach ($Mars->rovers as $key => $value):?>
<option value="<?php echo $key;?>" <?php if(isset($rover) && $rover == $key) {
echo "selected";
} ?>><?php echo $value;?></option>
<?php
endforeach;
endif;
?>
</select>
</div>
</div>
<!-- Button -->
<div class="form-group">
<div align="center" class="col-md-4">
<button id="enviar" type="submit" name="enviar" class="btn btn-success">Buscar Fotos</button>
</div
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<?php
if (isset($images) && !isset($images->photos)) {
echo '<script type="text/javascript">alert("Nada encontrado nessa data, tenta outra!?");</script>';
}else{
?>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="bootstrap/js/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
<?php if(isset($images)): ?>
<div class="container container-result" id="resultado">
<h2>Resultados:</h2>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>SOL</th>
<th>CAMERA</th>
<th>IMG</th>
<th>DATA</th>
<th>ROVER</th>
</tr>
</thead>
<tbody>
<?php
foreach ($images as $image) {
for ($i=0; $i < count($image); $i++) { ?>
<tr>
<td><?php echo $image[$i]->id;?></td>
<td><?php echo $image[$i]->sol ?></td>
<td><?php echo $image[$i]->camera->name?></td>
<td align="center">
<a href="<?php echo $image[$i]->img_src; ?>" target="_blank"><img align="center" style="width:50%" src="<?php echo $image[$i]->img_src; ?>" alt="Clique"></a>
</td>
<td><?php echo date("d/m/Y",strtotime($image[$i]->earth_date));?></td>
<td><?php echo $image[$i]->rover->name ?>
</td>
</tr>
<?php
}
}
endif;
}
?>
</tbody>
</table>
<?php if (isset($images) && isset($images->photos)):?>
<a href="#top">Voltar ao topo (nova pesquisa)</a>
<br>
<a href="#resultado">Voltar ao topo do resultado</a>
<?php endif; ?>
</div>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-69269217-1', 'auto');
ga('send', 'pageview');
</script>