-
Notifications
You must be signed in to change notification settings - Fork 0
/
ensemblefinal.php
220 lines (181 loc) · 6.92 KB
/
ensemblefinal.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?php session_start();
// error_reporting(E_ALL);
// ini_set('display_errors','1');
$tokenUsuario = md5('seg'.$_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT']);
if ($_SESSION['donoDaSessao'] != $tokenUsuario)
{
header('Location: index.php');
}
?><html lang="pt-BR">
<?php
require_once('classes/experimento.class.php');
require_once('classes/conexao.class.php');
$conexao = new Conexao;
$conn = $conexao->Conectar();
$Experimento = new Experimento();
$Experimento->conn = $conn;
$op=$_REQUEST['op'];
$id=$_REQUEST['id'];
$hash = md5($id);
$Experimento->getById($id);
$Experimento->getPath($id);
$idexperiment = $Experimento->idexperiment;//= $row['nomepropriedade'];
$pngCutPath = $Experimento->pngCutPath;
$rasterCutPath = $Experimento->rasterCutPath;
$pngBinPath = $Experimento->pngBinPath;
$pngContPath = $Experimento->pngContPath;
$isImageCut = $Experimento->isImageCut;
$isImageCut = $isImageCut === 't'? true: false;
$pngPath = $Experimento->pngPath;
$tiffPath = $Experimento->tiffPath;
$rasterPngPath = $Experimento->rasterPngPath;
$rasterPngPath = str_replace("/var/www/html/rafael/modelr","https://model-r.jbrj.gov.br",$rasterPngPath);
$novoRaster;
if(dirname(__FILE__) !== '/var/www/html/rafael/modelr'){
$imageModelFolder = "../temp/result/" . $hash;
$baseUrl = '../';
} else {
$imageModelFolder = "temp/result/" . $hash;
$baseUrl = './';
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Model-R </title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="fonts/css/font-awesome.min.css" rel="stylesheet">
<link href="css/animate.min.css" rel="stylesheet">
<!-- Custom styling plus plugins -->
<link href="css/custom.css" rel="stylesheet">
<link href="css/icheck/flat/green.css" rel="stylesheet">
<script src="js/jquery.min.js"></script>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map3 {
height: 65%;
}
</style>
<!--[if lt IE 9]>
<script src="../assets/js/ie8-responsive-file-warning.js"></script>
<![endif]-->
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_content">
<div class="row">
<div class="x_title">
<h2>Ensemble Final <small></small><a class="btn btn-default btn-sm" onClick="downloadZip();" data-toggle="tooltip" data-placement="top" title="Baixar ZIP" style="margin-top: 4px;">Download</a></h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<?php
$sql = "select distinct(taxon) from modelr.occurrence where idexperiment=" . $id . "and (idstatusoccurrence = 17 or idstatusoccurrence = 4)";
$res = pg_exec($conn,$sql);
$results_array = array();
$contadorMap = 0;
while ($row = pg_fetch_array($res))
{
$log_directory = $imageModelFolder.'/'.$row['taxon'].'/present/ensemble';
if (is_dir($log_directory))
{
$contadorMap = $contadorMap + 1;
echo '<div class="col-md-12 image-model" >';
if(count(scandir($log_directory)) > 2){
echo '<h2 style="margin-top: 20px; margin-bottom:20px;">' . $row['taxon'] . '</h2>';
}
if ($handle = opendir($log_directory))
{
//Notice the parentheses I added:
while(($file = readdir($handle)) !== FALSE)
{
$tamanho = strlen($file);
list ($arquivo, $ext) = preg_split ('[.]', $file);
$ext = substr($file,-3);
if (($file != 'ensemble_geral_legend.png') &&
($file != 'ensemble_geral.png')
)
{
if ($ext=='png' && !strpos($file, '_without_margins'))
{
//echo $ext.'<br>';
?>
<div class="col-md-3 image-model">
<a href="<?php echo $log_directory.'/'.$file;?>" target="result">
<img src="<?php echo $log_directory.'/'.$file;?>" class="img-thumbnail" alt="Cinque Terre" width="304" height="236">
<p><?php //echo $log_directory.'/'.$file;?></a><br>
<a href="<?php echo $log_directory.'/'.$file;?>" class="btn btn-default btn-sm download-button" download data-toggle="tooltip" data-placement="top" title data-original-title="Baixar arquivo PNG"><i class="fa fa-download"></i>PNG</a>
<a href="<?php echo str_replace('png','tif',$log_directory.'/'.$file);?>" class="btn btn-default btn-sm download-button" download data-toggle="tooltip" data-placement="top" title data-original-title="Baixar arquivo Raster"><i class="fa fa-download"></i>RASTER</a>
<?php //echo str_replace('.png','.tiff',$log_directory.'/'.$file);?>
</p>
</div>
<?php
$results_array[] = $file;
$conta_arquivos++;
}
}
}
closedir($handle);
}
echo '</div>';
}
}
//Output findings
?>
<!-- end pop-over -->
<!-- end pop-over -->
</div>
</div>
</div>
</div>
</div> <!-- table panel -->
</div>
<!-- scripts -->
<script>
function downloadZip(tipo){
document.getElementById('frmmodelos').target="_blank";
document.getElementById('frmmodelos').method="POST";
document.getElementById('frmmodelos').action='<?php echo $baseUrl;?>downloadZip.php?arquivo=<?php echo $id;?>';
document.getElementById('frmmodelos').submit();
}
function SalvarMapa() {
//alert('');
var specie = 'none';
for(var i = 0; i < document.getElementsByName('select-map-radio[]').length; i++){
if(document.getElementsByName('select-map-radio[]')[i].checked){
specie = document.getElementsByName('select-map-radio[]')[i].value;
}
}
var salvarmapa = document.getElementById('cmboxescolhermapa');
//console.log(salvarmapa)
//console.log(salvarmapa.value)
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var rasterPath = xmlhttp.responseText;
pngCutPath = '';
rasterCutPath = '';
isImageCut = false;
rasterPngPath = rasterPath;
//initMapExpResultado();
//window.location.href = "www.mysite.com/page2.php";
}
}
xmlhttp.open("GET",'controleCorteRaster.php?expid='+<?php echo $id;?>+'&op=T&specie=' + specie + '&png=' + salvarmapa.value,true);
xmlhttp.send();
}
</script>