Commit 8558eedbd2236d3ed9990784ee3830cf07c36d07

Authored by Edmar Moretti
1 parent a9c4e1fe

--no commit message

ferramentas/upload/index.js.php
@@ -83,7 +83,8 @@ i3GEOF.upload = { @@ -83,7 +83,8 @@ i3GEOF.upload = {
83 '<p class="paragrafo" >shp: <br><input class=digitar type="file" size=42 name="i3GEOuploadshp" style="top:0px;left:0px;cursor:pointer;"></p>' + 83 '<p class="paragrafo" >shp: <br><input class=digitar type="file" size=42 name="i3GEOuploadshp" style="top:0px;left:0px;cursor:pointer;"></p>' +
84 '<p class="paragrafo" >shx: <br><input class=digitar type="file" size=42 name="i3GEOuploadshx" style="top:0px;left:0px;cursor:pointer;"></p>' + 84 '<p class="paragrafo" >shx: <br><input class=digitar type="file" size=42 name="i3GEOuploadshx" style="top:0px;left:0px;cursor:pointer;"></p>' +
85 '<p class="paragrafo" >dbf: <br><input class=digitar type="file" size=42 name="i3GEOuploaddbf" style="top:0px;left:0px;cursor:pointer;"></p>' + 85 '<p class="paragrafo" >dbf: <br><input class=digitar type="file" size=42 name="i3GEOuploaddbf" style="top:0px;left:0px;cursor:pointer;"></p>' +
86 - '<p class="paragrafo" >Tipo: ' + 86 + '<p class="paragrafo" >pasta no servidor<br>onde os dados serão armazenados:<br><input class=digitar type="text" size=50 name="dirDestino" style="top:0px;left:0px;cursor:pointer;"></p>' +
  87 + '<p class="paragrafo" >Tipo de geometria: ' +
87 ' <select id=tipo name=tipo >' + 88 ' <select id=tipo name=tipo >' +
88 ' <option value="">não conhecido</option>' + 89 ' <option value="">não conhecido</option>' +
89 ' <option value="1">pontual</option>' + 90 ' <option value="1">pontual</option>' +
@@ -113,8 +114,8 @@ i3GEOF.upload = { @@ -113,8 +114,8 @@ i3GEOF.upload = {
113 }; 114 };
114 titulo = "Upload de shapefile <a class=ajuda_usuario target=_blank href='" + i3GEO.configura.locaplic + "/ajuda_usuario.php?idcategoria=4&idajuda=27' >&nbsp;&nbsp;&nbsp;</a>"; 115 titulo = "Upload de shapefile <a class=ajuda_usuario target=_blank href='" + i3GEO.configura.locaplic + "/ajuda_usuario.php?idcategoria=4&idajuda=27' >&nbsp;&nbsp;&nbsp;</a>";
115 janela = i3GEO.janela.cria( 116 janela = i3GEO.janela.cria(
116 - "320px",  
117 - "400px", 117 + "350px",
  118 + "450px",
118 "", 119 "",
119 "", 120 "",
120 "", 121 "",
ferramentas/upload/upload.php
1 <?php 1 <?php
  2 +//
  3 +//caso o usuário seja um administrador, ele pode enviar um nome de diretório onde os arquivos serão armazenados
  4 +//na variável $dirDestino
  5 +//
2 require_once("../../classesphp/pega_variaveis.php"); 6 require_once("../../classesphp/pega_variaveis.php");
3 require_once("../../classesphp/funcoes_gerais.php"); 7 require_once("../../classesphp/funcoes_gerais.php");
4 include_once ("../../classesphp/carrega_ext.php"); 8 include_once ("../../classesphp/carrega_ext.php");
5 error_reporting(E_ALL); 9 error_reporting(E_ALL);
6 session_name("i3GeoPHP"); 10 session_name("i3GeoPHP");
7 -if (isset($g_sid))  
8 -{session_id($g_sid);}  
9 -session_start();  
10 -foreach(array_keys($_SESSION) as $k)  
11 -{eval("\$".$k."='".$_SESSION[$k]."';");}  
12 -$postgis_mapa = $_SESSION["postgis_mapa"]; 11 +if (isset($g_sid)){
  12 + session_id($g_sid);
  13 + session_start();
  14 + foreach(array_keys($_SESSION) as $k)
  15 + {eval("\$".$k."='".$_SESSION[$k]."';");}
  16 +}
13 ?> 17 ?>
14 <html> 18 <html>
15 <head> 19 <head>
@@ -22,9 +26,18 @@ $postgis_mapa = $_SESSION[&quot;postgis_mapa&quot;]; @@ -22,9 +26,18 @@ $postgis_mapa = $_SESSION[&quot;postgis_mapa&quot;];
22 if (isset($_FILES['i3GEOuploadshp']['name'])) 26 if (isset($_FILES['i3GEOuploadshp']['name']))
23 { 27 {
24 require_once ("../../ms_configura.php"); 28 require_once ("../../ms_configura.php");
25 - $mapa = ms_newMapObj($map_file);  
26 echo "<p class='paragrafo' >Carregando o arquivo...</p>"; 29 echo "<p class='paragrafo' >Carregando o arquivo...</p>";
27 - $dirmap = dirname($map_file); 30 + if(isset($map_file)){
  31 + $mapa = ms_newMapObj($map_file);
  32 + $dirmap = dirname($map_file);
  33 + }
  34 + if(isset($dirDestino)){
  35 + $dirmap = $dirDestino;
  36 + if(verificaEditores() == "nao")
  37 + {echo "<p class='paragrafo' >Você não é um editor cadastrado. Não pode gravar fora do diretório temporário";paraAguarde();exit;}
  38 + if(!file_exists($dirmap))
  39 + {echo "<p class='paragrafo' >Pasta não existe no servidor";paraAguarde();exit;}
  40 + }
28 //verifica nomes 41 //verifica nomes
29 verificaNome($_FILES['i3GEOuploadshp']['name']); 42 verificaNome($_FILES['i3GEOuploadshp']['name']);
30 verificaNome($_FILES['i3GEOuploadshx']['name']); 43 verificaNome($_FILES['i3GEOuploadshx']['name']);
@@ -33,6 +46,8 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])) @@ -33,6 +46,8 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;]))
33 $nomePrefixo = str_replace(" ","_",removeAcentos(str_replace(".shp","",$_FILES['i3GEOuploadshp']['name']))); 46 $nomePrefixo = str_replace(" ","_",removeAcentos(str_replace(".shp","",$_FILES['i3GEOuploadshp']['name'])));
34 //sobe arquivo 47 //sobe arquivo
35 $Arquivo = $_FILES['i3GEOuploadshp']['tmp_name']; 48 $Arquivo = $_FILES['i3GEOuploadshp']['tmp_name'];
  49 + if(!file_exists($dirmap."/".$nomePrefixo.".shp"))
  50 + {echo "<p class='paragrafo' >Já existe um SHP com o nome ".$dirmap."/".$nomePrefixo;paraAguarde();exit;}
36 $status = move_uploaded_file($Arquivo,$dirmap."/".$nomePrefixo.".shp"); 51 $status = move_uploaded_file($Arquivo,$dirmap."/".$nomePrefixo.".shp");
37 if($status != 1) 52 if($status != 1)
38 {echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo SHP";paraAguarde();exit;} 53 {echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo SHP";paraAguarde();exit;}
@@ -44,52 +59,55 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])) @@ -44,52 +59,55 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;]))
44 $status = move_uploaded_file($Arquivo,$dirmap."/".$nomePrefixo.".dbf"); 59 $status = move_uploaded_file($Arquivo,$dirmap."/".$nomePrefixo.".dbf");
45 if($status != 1) 60 if($status != 1)
46 {echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo DBF";paraAguarde();exit;} 61 {echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo DBF";paraAguarde();exit;}
47 - echo "<p class='paragrafo' >Arquivo enviado. Adicionando tema...</p>";  
48 - $novolayer = ms_newLayerObj($mapa);  
49 - $novolayer->set("data",$dirmap."/".$nomePrefixo.".shp");  
50 - $novolayer->set("name",$nomePrefixo.".shp");  
51 - $novolayer->setmetadata("TEMA",$nomePrefixo.".shp");  
52 - $novolayer->setmetadata("DOWNLOAD","SIM");  
53 - $sfileObj = ms_newShapefileObj($dirmap."/".$nomePrefixo.".shp", -1);  
54 - if(!isset($tipo) || $tipo == "")  
55 - {$tipo = $sfileObj->type;}  
56 - if ($tipo == 1){$novolayer->set("type",MS_LAYER_POINT);} // ponto  
57 - if ($tipo == 3){$novolayer->set("type",MS_LAYER_LINE);}  
58 - if ($tipo == 5){$novolayer->set("type",MS_LAYER_POLYGON);}  
59 - $novolayer->setmetadata("TEMALOCAL","SIM");  
60 - $novolayer->setmetadata("CLASSE","SIM");  
61 - $novolayer->setmetadata("TEXTO","NAO");  
62 - //if (($tipo != 3) and ($tipo != 8 )){$novolayer->set("type",0);}  
63 - $novolayer->setfilter("");  
64 - $classe = ms_newClassObj($novolayer);  
65 - $classe->set("name","");  
66 - $estilo = ms_newStyleObj($classe);  
67 - if ($tipo == 1)  
68 - {  
69 - $estilo->set("symbolname","ponto");  
70 - $estilo->set("size",6);  
71 - }  
72 - $estilo->color->setrgb(200,50,0);  
73 - $estilo->outlinecolor->setrgb(0,0,0);  
74 - // le os itens  
75 - $novolayer->set("status",MS_DEFAULT);  
76 - $abriu = $novolayer->open();  
77 - $items = $novolayer->getItems();  
78 - $fechou = $novolayer->close();  
79 - if ($items != "")  
80 - {  
81 - $its = implode(",",$items);  
82 - $novolayer->setmetadata("ITENS",$its);  
83 - $novolayer->setmetadata("ITENSDESC",$its);  
84 - $novolayer->set("template","none.htm"); 62 + echo "<p class='paragrafo' >Arquivo enviado.</p>";
  63 + if(isset($map_file)){
  64 + echo "<p class='paragrafo' >Adicionando tema...</p>";
  65 + $novolayer = ms_newLayerObj($mapa);
  66 + $novolayer->set("data",$dirmap."/".$nomePrefixo.".shp");
  67 + $novolayer->set("name",$nomePrefixo.".shp");
  68 + $novolayer->setmetadata("TEMA",$nomePrefixo.".shp");
  69 + $novolayer->setmetadata("DOWNLOAD","SIM");
  70 + $sfileObj = ms_newShapefileObj($dirmap."/".$nomePrefixo.".shp", -1);
  71 + if(!isset($tipo) || $tipo == "")
  72 + {$tipo = $sfileObj->type;}
  73 + if ($tipo == 1){$novolayer->set("type",MS_LAYER_POINT);} // ponto
  74 + if ($tipo == 3){$novolayer->set("type",MS_LAYER_LINE);}
  75 + if ($tipo == 5){$novolayer->set("type",MS_LAYER_POLYGON);}
  76 + $novolayer->setmetadata("TEMALOCAL","SIM");
  77 + $novolayer->setmetadata("CLASSE","SIM");
  78 + $novolayer->setmetadata("TEXTO","NAO");
  79 + //if (($tipo != 3) and ($tipo != 8 )){$novolayer->set("type",0);}
  80 + $novolayer->setfilter("");
  81 + $classe = ms_newClassObj($novolayer);
  82 + $classe->set("name","");
  83 + $estilo = ms_newStyleObj($classe);
  84 + if ($tipo == 1)
  85 + {
  86 + $estilo->set("symbolname","ponto");
  87 + $estilo->set("size",6);
  88 + }
  89 + $estilo->color->setrgb(200,50,0);
  90 + $estilo->outlinecolor->setrgb(0,0,0);
  91 + // le os itens
  92 + $novolayer->set("status",MS_DEFAULT);
  93 + $abriu = $novolayer->open();
  94 + $items = $novolayer->getItems();
  95 + $fechou = $novolayer->close();
  96 + if ($items != "")
  97 + {
  98 + $its = implode(",",$items);
  99 + $novolayer->setmetadata("ITENS",$its);
  100 + $novolayer->setmetadata("ITENSDESC",$its);
  101 + $novolayer->set("template","none.htm");
  102 + }
  103 + if(isset($uploadEPSG) && $uploadEPSG != "")
  104 + {$novolayer->setProjection("init=epsg:".$uploadEPSG);}
  105 + //$adiciona = ms_newLayerObj($mapa, $novolayer);
  106 + $salvo = $mapa->save($map_file);
  107 + //grava os templates de cada tema
  108 + echo "<p class='paragrafo' >Tema criado!!! Redesenhando o mapa.";
  109 + echo "<script>window.parent.i3GEO.atualiza()</script>";
85 } 110 }
86 - if(isset($uploadEPSG) && $uploadEPSG != "")  
87 - {$novolayer->setProjection("init=epsg:".$uploadEPSG);}  
88 - //$adiciona = ms_newLayerObj($mapa, $novolayer);  
89 - $salvo = $mapa->save($map_file);  
90 - //grava os templates de cada tema  
91 - echo "<p class='paragrafo' >Tema criado!!! Redesenhando o mapa.";  
92 - echo "<script>window.parent.i3GEO.atualiza()</script>";  
93 } 111 }
94 else 112 else
95 { 113 {
@@ -97,7 +115,7 @@ else @@ -97,7 +115,7 @@ else
97 } 115 }
98 paraAguarde(); 116 paraAguarde();
99 function paraAguarde(){ 117 function paraAguarde(){
100 - echo "<script>window.parent.i3GEOF.upload.aguarde.visibility='hidden';</script>"; 118 + echo "<script>try{window.parent.i3GEOF.upload.aguarde.visibility='hidden';}catch(e){};</script>";
101 } 119 }
102 function verificaNome($nome) 120 function verificaNome($nome)
103 { 121 {
interface/openlayers.htm
@@ -100,7 +100,7 @@ @@ -100,7 +100,7 @@
100 </div> 100 </div>
101 </div> 101 </div>
102 </div> 102 </div>
103 -<script src="../classesjs/i3geo.js"></script> 103 +<script src="../classesjs/i3geonaocompacto.js"></script>
104 <script src="../pacotes/openlayers/OpenLayers211.js.php"></script> 104 <script src="../pacotes/openlayers/OpenLayers211.js.php"></script>
105 <!-- estilo necessário para a ferramenta de edição --> 105 <!-- estilo necessário para a ferramenta de edição -->
106 <style> 106 <style>