Commit ba4ca69fc682318ca1c10d15c93afe6cb7c37081
1 parent
cd4a9577
Exists in
master
Separacao do codigo utilizado no upload de shp do sistema de administracao e das ferramentas
Showing
3 changed files
with
65 additions
and
104 deletions
Show diff stats
classesphp/mapa_controle.php
| @@ -122,7 +122,7 @@ $interfaceTemp = $interface; | @@ -122,7 +122,7 @@ $interfaceTemp = $interface; | ||
| 122 | //TEMA2SLD e usado por datadownload.htm | 122 | //TEMA2SLD e usado por datadownload.htm |
| 123 | //PEGAMAPAS e utilizado em varias funcoes | 123 | //PEGAMAPAS e utilizado em varias funcoes |
| 124 | // | 124 | // |
| 125 | -if ($funcao != "pegaTodosTemas" && $funcao != "download3" && $funcao != "listainterfaces" && $funcao != "pegalistadetemas" && $funcao != "pegalistadeSubgrupos" && $funcao != "procurartemasestrela" && $funcao != "pegalistadegrupos" && $funcao != "pegalistademenus" && $funcao != "criaMapa" && strtoupper($funcao) != "TEMA2SLD" && strtoupper($funcao) != "PEGAMAPAS"){ | 125 | +if ($funcao != "listaEpsg" && $funcao != "pegaTodosTemas" && $funcao != "download3" && $funcao != "listainterfaces" && $funcao != "pegalistadetemas" && $funcao != "pegalistadeSubgrupos" && $funcao != "procurartemasestrela" && $funcao != "pegalistadegrupos" && $funcao != "pegalistademenus" && $funcao != "criaMapa" && strtoupper($funcao) != "TEMA2SLD" && strtoupper($funcao) != "PEGAMAPAS"){ |
| 126 | session_name("i3GeoPHP"); | 126 | session_name("i3GeoPHP"); |
| 127 | if (isset($g_sid) && $g_sid != ""){ | 127 | if (isset($g_sid) && $g_sid != ""){ |
| 128 | session_id($g_sid); | 128 | session_id($g_sid); |
ferramentas/upload/index.js
| @@ -112,14 +112,6 @@ i3GEOF.upload = { | @@ -112,14 +112,6 @@ i3GEOF.upload = { | ||
| 112 | '<p class="paragrafo" >dbf: <br><input type="file" size=22 name="i3GEOuploaddbf" style="top:0px;left:0px;cursor:pointer;"></p>' + | 112 | '<p class="paragrafo" >dbf: <br><input type="file" size=22 name="i3GEOuploaddbf" style="top:0px;left:0px;cursor:pointer;"></p>' + |
| 113 | '<p class="paragrafo" >prj (opcional): <br><input type="file" size=22 name="i3GEOuploadprj" style="top:0px;left:0px;cursor:pointer;"></p>' + | 113 | '<p class="paragrafo" >prj (opcional): <br><input type="file" size=22 name="i3GEOuploadprj" style="top:0px;left:0px;cursor:pointer;"></p>' + |
| 114 | '</fieldset>'; | 114 | '</fieldset>'; |
| 115 | - if(i3GEO.parametros.editor === "sim"){ | ||
| 116 | - ins += '<fieldset class=subbloco >' + | ||
| 117 | - '<p class="paragrafo" >'+$trad('pastaArmazenamento',i3GEOF.upload.dicionario)+':</p>' + | ||
| 118 | - '<div class="i3geoForm i3geoFormIconeEdita" ><input type="text" name="dirDestino" id="dirDestino" /></div>' + | ||
| 119 | - " <img onclick='i3GEO.util.navegadorDir(\"dirDestino\",false,false,false,true);' src='"+i3GEO.configura.locaplic+"/imagens/ic_zoom.png' style='cursor:pointer;position :relative;top:2px'/></p>" + | ||
| 120 | - '<p class="paragrafo" ><input type=checkbox name=i3GEOuploadCriaMapfile id=i3GEOuploadCriaMapfile /> '+$trad('criaMapfile',i3GEOF.upload.dicionario) + | ||
| 121 | - '</fieldset>'; | ||
| 122 | - } | ||
| 123 | ins += '<fieldset class=subbloco >' + | 115 | ins += '<fieldset class=subbloco >' + |
| 124 | '<p class="paragrafo" >'+$trad('tipoGeom',i3GEOF.upload.dicionario)+': </p>' + | 116 | '<p class="paragrafo" >'+$trad('tipoGeom',i3GEOF.upload.dicionario)+': </p>' + |
| 125 | ' <div class=styled-select >' + | 117 | ' <div class=styled-select >' + |
ferramentas/upload/upload.php
| @@ -17,6 +17,12 @@ if(isset($_GET["g_sid"]) && $_GET["g_sid"] != ""){ | @@ -17,6 +17,12 @@ if(isset($_GET["g_sid"]) && $_GET["g_sid"] != ""){ | ||
| 17 | session_start(); | 17 | session_start(); |
| 18 | $map_file = $_SESSION["map_file"]; | 18 | $map_file = $_SESSION["map_file"]; |
| 19 | } | 19 | } |
| 20 | +else{ | ||
| 21 | + exit; | ||
| 22 | +} | ||
| 23 | +if(!file_exists($map_file)){ | ||
| 24 | + exit; | ||
| 25 | +} | ||
| 20 | if (ob_get_level() == 0) ob_start(); | 26 | if (ob_get_level() == 0) ob_start(); |
| 21 | ?> | 27 | ?> |
| 22 | <html> | 28 | <html> |
| @@ -42,18 +48,10 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | @@ -42,18 +48,10 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | ||
| 42 | ob_flush(); | 48 | ob_flush(); |
| 43 | flush(); | 49 | flush(); |
| 44 | sleep(1); | 50 | sleep(1); |
| 45 | - if(isset($map_file)){ | ||
| 46 | - $mapa = ms_newMapObj($map_file); | ||
| 47 | - $dirmap = dirname($map_file); | ||
| 48 | - } | ||
| 49 | - if(isset($dirDestino) && $dirDestino != ""){ | ||
| 50 | - $dirmap = $dirDestino; | ||
| 51 | - include_once(dirname(__FILE__)."/../../admin/php/login.php"); | ||
| 52 | - if(verificaOperacaoSessao("admin/php/editortexto") == false){ | ||
| 53 | - echo "Vc nao pode salvar os dados no servidor em uma pasta específica";exit; | ||
| 54 | - } | ||
| 55 | - if(!file_exists($dirmap)) | ||
| 56 | - {echo "<p class='paragrafo' >Pasta não existe no servidor";paraAguarde();exit;} | 51 | + $mapa = ms_newMapObj($map_file); |
| 52 | + $dirmap = dirname($map_file); | ||
| 53 | + if(!file_exists($dirmap)){ | ||
| 54 | + exit; | ||
| 57 | } | 55 | } |
| 58 | //verifica nomes | 56 | //verifica nomes |
| 59 | verificaNome($_FILES['i3GEOuploadshp']['name']); | 57 | verificaNome($_FILES['i3GEOuploadshp']['name']); |
| @@ -104,6 +102,7 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | @@ -104,6 +102,7 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | ||
| 104 | 102 | ||
| 105 | $checkphp = fileContemString($dirmap."/".$nomePrefixo.".prj","<?"); | 103 | $checkphp = fileContemString($dirmap."/".$nomePrefixo.".prj","<?"); |
| 106 | if($checkphp == true){ | 104 | if($checkphp == true){ |
| 105 | + echo "Arquivo prj invalido"; | ||
| 107 | unlink($dirmap."/".$nomePrefixo.".shp"); | 106 | unlink($dirmap."/".$nomePrefixo.".shp"); |
| 108 | unlink($dirmap."/".$nomePrefixo.".dbf"); | 107 | unlink($dirmap."/".$nomePrefixo.".dbf"); |
| 109 | unlink($dirmap."/".$nomePrefixo.".shx"); | 108 | unlink($dirmap."/".$nomePrefixo.".shx"); |
| @@ -112,6 +111,7 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | @@ -112,6 +111,7 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | ||
| 112 | } | 111 | } |
| 113 | $checkphp = fileContemString($dirmap."/".$nomePrefixo.".shx","<?"); | 112 | $checkphp = fileContemString($dirmap."/".$nomePrefixo.".shx","<?"); |
| 114 | if($checkphp == true){ | 113 | if($checkphp == true){ |
| 114 | + echo "Arquivo shx invalido"; | ||
| 115 | unlink($dirmap."/".$nomePrefixo.".shp"); | 115 | unlink($dirmap."/".$nomePrefixo.".shp"); |
| 116 | unlink($dirmap."/".$nomePrefixo.".dbf"); | 116 | unlink($dirmap."/".$nomePrefixo.".dbf"); |
| 117 | unlink($dirmap."/".$nomePrefixo.".shx"); | 117 | unlink($dirmap."/".$nomePrefixo.".shx"); |
| @@ -120,6 +120,7 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | @@ -120,6 +120,7 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | ||
| 120 | } | 120 | } |
| 121 | $checkphp = fileContemString($dirmap."/".$nomePrefixo.".dbf","<?"); | 121 | $checkphp = fileContemString($dirmap."/".$nomePrefixo.".dbf","<?"); |
| 122 | if($checkphp == true){ | 122 | if($checkphp == true){ |
| 123 | + echo "Arquivo dbf invalido"; | ||
| 123 | unlink($dirmap."/".$nomePrefixo.".shp"); | 124 | unlink($dirmap."/".$nomePrefixo.".shp"); |
| 124 | unlink($dirmap."/".$nomePrefixo.".dbf"); | 125 | unlink($dirmap."/".$nomePrefixo.".dbf"); |
| 125 | unlink($dirmap."/".$nomePrefixo.".shx"); | 126 | unlink($dirmap."/".$nomePrefixo.".shx"); |
| @@ -130,91 +131,59 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | @@ -130,91 +131,59 @@ if (isset($_FILES['i3GEOuploadshp']['name'])) | ||
| 130 | echo "<p class='paragrafo' >Arquivo enviado.</p>"; | 131 | echo "<p class='paragrafo' >Arquivo enviado.</p>"; |
| 131 | echo "<p class='paragrafo'></p>"; | 132 | echo "<p class='paragrafo'></p>"; |
| 132 | //nesse caso o formulario de upload esta sendo executado de dentro de um mapa interativo, por isso o mapfile ja existe | 133 | //nesse caso o formulario de upload esta sendo executado de dentro de um mapa interativo, por isso o mapfile ja existe |
| 133 | - if(isset($map_file)){ | ||
| 134 | - echo "<p class='paragrafo' >Adicionando tema...</p>"; | ||
| 135 | - ob_flush(); | ||
| 136 | - flush(); | ||
| 137 | - sleep(1); | ||
| 138 | - $novolayer = ms_newLayerObj($mapa); | ||
| 139 | - $novolayer->set("data",$dirmap."/".$nomePrefixo.".shp"); | ||
| 140 | - $novolayer->set("name",$_FILES['i3GEOuploadshp']['name']); | ||
| 141 | - $novolayer->setmetadata("TEMA",$_FILES['i3GEOuploadshp']['name']); | ||
| 142 | - $novolayer->setmetadata("DOWNLOAD","SIM"); | ||
| 143 | - $sfileObj = ms_newShapefileObj($dirmap."/".$nomePrefixo.".shp", -1); | ||
| 144 | - if(!isset($tipo) || $tipo == "") | ||
| 145 | - {$tipo = $sfileObj->type;} | ||
| 146 | - if ($tipo == 1){$novolayer->set("type",MS_LAYER_POINT);} // ponto | ||
| 147 | - if ($tipo == 3){$novolayer->set("type",MS_LAYER_LINE);} | ||
| 148 | - if ($tipo == 5){$novolayer->set("type",MS_LAYER_POLYGON);} | ||
| 149 | - $novolayer->setmetadata("TEMALOCAL","SIM"); | ||
| 150 | - $novolayer->setmetadata("CLASSE","SIM"); | ||
| 151 | - $novolayer->setmetadata("TEXTO","NAO"); | ||
| 152 | - //if (($tipo != 3) and ($tipo != 8 )){$novolayer->set("type",0);} | ||
| 153 | - $novolayer->setfilter(""); | ||
| 154 | - $classe = ms_newClassObj($novolayer); | ||
| 155 | - $classe->set("name",""); | ||
| 156 | - $estilo = ms_newStyleObj($classe); | ||
| 157 | - if ($tipo == 1) | ||
| 158 | - { | ||
| 159 | - $estilo->set("symbolname","ponto"); | ||
| 160 | - $estilo->set("size",6); | ||
| 161 | - } | ||
| 162 | - $estilo->color->setrgb(200,50,0); | ||
| 163 | - $estilo->outlinecolor->setrgb(0,0,0); | ||
| 164 | - // le os itens | ||
| 165 | - $novolayer->set("status",MS_DEFAULT); | ||
| 166 | - $abriu = $novolayer->open(); | ||
| 167 | - $items = $novolayer->getItems(); | ||
| 168 | - $fechou = $novolayer->close(); | ||
| 169 | - if ($items != "") | ||
| 170 | - { | ||
| 171 | - $its = implode(",",$items); | ||
| 172 | - $novolayer->setmetadata("ITENS",$its); | ||
| 173 | - $novolayer->setmetadata("ITENSDESC",$its); | ||
| 174 | - $novolayer->set("template","none.htm"); | ||
| 175 | - } | ||
| 176 | - if(isset($_GET["uploadEPSG"]) && $_GET["uploadEPSG"] != ""){ | ||
| 177 | - $novolayer->setProjection("init=epsg:".$_GET["uploadEPSG"]); | ||
| 178 | - } | ||
| 179 | - if(file_exists($dirmap."/".$nomePrefixo.".prj")){ | ||
| 180 | - $novolayer->setProjection("AUTO"); | ||
| 181 | - } | ||
| 182 | - //$adiciona = ms_newLayerObj($mapa, $novolayer); | ||
| 183 | - $salvo = $mapa->save($map_file); | ||
| 184 | - //grava os templates de cada tema | ||
| 185 | - echo "<b><p class='paragrafo' >Tema criado!!! Redesenhando o mapa."; | ||
| 186 | - echo "<script>window.scrollTo(0,10000);window.parent.i3GEO.atualiza()</script>"; | 134 | + echo "<p class='paragrafo' >Adicionando tema...</p>"; |
| 135 | + ob_flush(); | ||
| 136 | + flush(); | ||
| 137 | + sleep(1); | ||
| 138 | + $novolayer = ms_newLayerObj($mapa); | ||
| 139 | + $novolayer->set("data",$dirmap."/".$nomePrefixo.".shp"); | ||
| 140 | + $novolayer->set("name",$_FILES['i3GEOuploadshp']['name']); | ||
| 141 | + $novolayer->setmetadata("TEMA",$_FILES['i3GEOuploadshp']['name']); | ||
| 142 | + $novolayer->setmetadata("DOWNLOAD","SIM"); | ||
| 143 | + $sfileObj = ms_newShapefileObj($dirmap."/".$nomePrefixo.".shp", -1); | ||
| 144 | + if(!isset($tipo) || $tipo == "") | ||
| 145 | + {$tipo = $sfileObj->type;} | ||
| 146 | + if ($tipo == 1){$novolayer->set("type",MS_LAYER_POINT);} // ponto | ||
| 147 | + if ($tipo == 3){$novolayer->set("type",MS_LAYER_LINE);} | ||
| 148 | + if ($tipo == 5){$novolayer->set("type",MS_LAYER_POLYGON);} | ||
| 149 | + $novolayer->setmetadata("TEMALOCAL","SIM"); | ||
| 150 | + $novolayer->setmetadata("CLASSE","SIM"); | ||
| 151 | + $novolayer->setmetadata("TEXTO","NAO"); | ||
| 152 | + //if (($tipo != 3) and ($tipo != 8 )){$novolayer->set("type",0);} | ||
| 153 | + $novolayer->setfilter(""); | ||
| 154 | + $classe = ms_newClassObj($novolayer); | ||
| 155 | + $classe->set("name",""); | ||
| 156 | + $estilo = ms_newStyleObj($classe); | ||
| 157 | + if ($tipo == 1) | ||
| 158 | + { | ||
| 159 | + $estilo->set("symbolname","ponto"); | ||
| 160 | + $estilo->set("size",6); | ||
| 187 | } | 161 | } |
| 188 | - elseif($i3GEOuploadCriaMapfile == "on"){ | ||
| 189 | - //verifica se o usuario marcou a opcao de cria mapfile | ||
| 190 | - //nesse caso o aplicativo de upload esta sendo executado de dentro do sistema de administracao, e o mapfile devera | ||
| 191 | - //ser criado e registrado no sistema | ||
| 192 | - $nome = $nomePrefixo; | ||
| 193 | - $codigo = $nomePrefixo; | ||
| 194 | - $it = $nomePrefixo; | ||
| 195 | - $en = $nomePrefixo; | ||
| 196 | - $es = $nomePrefixo; | ||
| 197 | - $sfileObj = ms_newShapefileObj($dirmap."/".$nomePrefixo.".shp", -1); | ||
| 198 | - if(!isset($tipo) || $tipo == ""){ | ||
| 199 | - $tipo = $sfileObj->type; | ||
| 200 | - } | ||
| 201 | - if ($tipo == 1){ | ||
| 202 | - $tipoLayer = "point"; | ||
| 203 | - } | ||
| 204 | - if ($tipo == 3){ | ||
| 205 | - $tipoLayer = "line"; | ||
| 206 | - } | ||
| 207 | - if ($tipo == 5){ | ||
| 208 | - $tipoLayer = "polygon"; | ||
| 209 | - } | ||
| 210 | - $funcao = "CRIARNOVOMAP"; | ||
| 211 | - $output = "retorno"; | ||
| 212 | - $data = $dirmap."/".$nomePrefixo.".shp"; | ||
| 213 | - include_once($locaplic."/admin/php/editormapfile.php"); | ||
| 214 | - echo "<b><p class='paragrafo' >Criado!!!<br>"; | ||
| 215 | - echo "Para editar clique: <a href='../../admin/html/editormapfile.html' target=_blank >editar</a>"; | ||
| 216 | - echo "<script>window.scrollTo(0,10000);i3GEO.util.insereCookie('I3GEOletraAdmin','".$nomePrefixo."');</script>"; | 162 | + $estilo->color->setrgb(200,50,0); |
| 163 | + $estilo->outlinecolor->setrgb(0,0,0); | ||
| 164 | + // le os itens | ||
| 165 | + $novolayer->set("status",MS_DEFAULT); | ||
| 166 | + $abriu = $novolayer->open(); | ||
| 167 | + $items = $novolayer->getItems(); | ||
| 168 | + $fechou = $novolayer->close(); | ||
| 169 | + if ($items != "") | ||
| 170 | + { | ||
| 171 | + $its = implode(",",$items); | ||
| 172 | + $novolayer->setmetadata("ITENS",$its); | ||
| 173 | + $novolayer->setmetadata("ITENSDESC",$its); | ||
| 174 | + $novolayer->set("template","none.htm"); | ||
| 175 | + } | ||
| 176 | + if(isset($_GET["uploadEPSG"]) && $_GET["uploadEPSG"] != ""){ | ||
| 177 | + $novolayer->setProjection("init=epsg:".$_GET["uploadEPSG"]); | ||
| 178 | + } | ||
| 179 | + if(file_exists($dirmap."/".$nomePrefixo.".prj")){ | ||
| 180 | + $novolayer->setProjection("AUTO"); | ||
| 217 | } | 181 | } |
| 182 | + //$adiciona = ms_newLayerObj($mapa, $novolayer); | ||
| 183 | + $salvo = $mapa->save($map_file); | ||
| 184 | + //grava os templates de cada tema | ||
| 185 | + echo "<b><p class='paragrafo' >Tema criado!!! Redesenhando o mapa."; | ||
| 186 | + echo "<script>window.scrollTo(0,10000);window.parent.i3GEO.atualiza()</script>"; | ||
| 218 | } | 187 | } |
| 219 | else | 188 | else |
| 220 | { | 189 | { |