Commit ce52c40631dfed3c39a4e0215c914f8b98fb6aa7
1 parent
94e29cf2
Exists in
master
and in
7 other branches
Correção na função de download de shapefile nos casos em que a extensão dbase nã…
…o estiver carregada corretamente
Showing
1 changed file
with
25 additions
and
3 deletions
Show diff stats
classesphp/funcoes_gerais.php
| ... | ... | @@ -1884,9 +1884,15 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
| 1884 | 1884 | // |
| 1885 | 1885 | //verifica a quantidade de registros no final |
| 1886 | 1886 | // |
| 1887 | + if(function_exists("dbase_open")) | |
| 1887 | 1888 | $db = dbase_open($nomeshp.".dbf", 0); |
| 1889 | + else | |
| 1890 | + $db = xbase_open($nomeshp.".dbf", 0); | |
| 1888 | 1891 | $record_numbers = dbase_numrecords($db); |
| 1892 | + if(function_exists("dbase_close")) | |
| 1889 | 1893 | dbase_close($db); |
| 1894 | + else | |
| 1895 | + xbase_close($db); | |
| 1890 | 1896 | if($record_numbers != $res_count){ |
| 1891 | 1897 | if(file_exists($nomeshp.".dbf")) |
| 1892 | 1898 | {unlink($nomeshp.".dbf");} |
| ... | ... | @@ -1955,7 +1961,11 @@ function downloadTema2($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa) |
| 1955 | 1961 | if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) |
| 1956 | 1962 | {$map_tmp = ms_newMapObj($locaplic."/aplicmap/geral1windows.map");} |
| 1957 | 1963 | else |
| 1958 | - {$map_tmp = ms_newMapObj($locaplic."/aplicmap/geral1.map");} | |
| 1964 | + { | |
| 1965 | + $map_tmp = @ms_newMapObj($locaplic."/aplicmap/geral1.map"); | |
| 1966 | + if(!$map_tmp) | |
| 1967 | + $map_tmp = @ms_newMapObj($locaplic."/aplicmap/geral1debian.map"); | |
| 1968 | + } | |
| 1959 | 1969 | $map_file = $dir_tmp."/".nomerandomico(20).".map"; |
| 1960 | 1970 | $map_tmp->save($map_file); |
| 1961 | 1971 | $nomeRand = false; |
| ... | ... | @@ -2123,8 +2133,14 @@ function downloadTema2($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa) |
| 2123 | 2133 | $nreg = ""; |
| 2124 | 2134 | if(count($resultado) == 3){ |
| 2125 | 2135 | $arq = $radtmp."/".$resultado[2]; |
| 2126 | - $db = dbase_open($arq, 0); | |
| 2127 | - if($db){$nreg = dbase_numrecords($db);} | |
| 2136 | + if(function_exists("dbase_open")){ | |
| 2137 | + $db = dbase_open($arq, 0); | |
| 2138 | + if($db){$nreg = dbase_numrecords($db);} | |
| 2139 | + } | |
| 2140 | + else{ | |
| 2141 | + $db = xbase_open($arq, 0); | |
| 2142 | + if($db){$nreg = xbase_numrecords($db);} | |
| 2143 | + } | |
| 2128 | 2144 | } |
| 2129 | 2145 | return array("arquivos"=>implode(",",$resultado),"nreg"=>$nreg); |
| 2130 | 2146 | } |
| ... | ... | @@ -2143,9 +2159,15 @@ Return: |
| 2143 | 2159 | {boolean} - true indica que não está vazio |
| 2144 | 2160 | */ |
| 2145 | 2161 | function verificaDBF($arq){ |
| 2162 | + if(function_exists("dbase_open")) | |
| 2146 | 2163 | $db = dbase_open($arq, 0); |
| 2164 | + else | |
| 2165 | + $db = xbase_open($arq, 0); | |
| 2147 | 2166 | if ($db) { |
| 2167 | + if(function_exists("dbase_numrecords")) | |
| 2148 | 2168 | $record_numbers = dbase_numrecords($db); |
| 2169 | + else | |
| 2170 | + $record_numbers = xbase_numrecords($db); | |
| 2149 | 2171 | if ($record_numbers > 0) |
| 2150 | 2172 | {return true;} |
| 2151 | 2173 | else | ... | ... |