Commit e8f17d64738e596165790d839f1a08d5872c6fb6
1 parent
4aba93f7
Exists in
master
Correção na biblioteca de geração de arquivos dbf. Fechamento da tag PHP e comen…
…tário da linha flush() na função de gravação de registros. Essa linha estava gerando um header que impede o download de arquivos shapefile zipados
Showing
5 changed files
with
41 additions
and
39 deletions
Show diff stats
pacotes/phpxbase/Column.class.php
| ... | ... | @@ -2,8 +2,8 @@ |
| 2 | 2 | /** |
| 3 | 3 | * ---------------------------------------------------------------- |
| 4 | 4 | * XBase |
| 5 | -* XBaseColumn.class.php | |
| 6 | -* | |
| 5 | +* XBaseColumn.class.php | |
| 6 | +* | |
| 7 | 7 | * Developer : Erwin Kooi |
| 8 | 8 | * released at : Nov 2005 |
| 9 | 9 | * last modified by : Erwin Kooi |
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | * You're free to use this code as long as you don't alter it |
| 13 | 13 | * Copyright (c) 2005 Cyane Dynamic Web Solutions |
| 14 | 14 | * Info? Mail to info@cyane.nl |
| 15 | -* | |
| 15 | +* | |
| 16 | 16 | * -------------------------------------------------------------- |
| 17 | 17 | * |
| 18 | 18 | * This class represents a DBF column |
| ... | ... | @@ -105,4 +105,5 @@ class XBaseColumn { |
| 105 | 105 | function getColIndex() { |
| 106 | 106 | return $this->colIndex; |
| 107 | 107 | } |
| 108 | -} | |
| 109 | 108 | \ No newline at end of file |
| 109 | +} | |
| 110 | +?> | |
| 110 | 111 | \ No newline at end of file | ... | ... |
pacotes/phpxbase/Record.class.php
| ... | ... | @@ -2,8 +2,8 @@ |
| 2 | 2 | /** |
| 3 | 3 | * ---------------------------------------------------------------- |
| 4 | 4 | * XBase |
| 5 | -* Record.class.php | |
| 6 | -* | |
| 5 | +* Record.class.php | |
| 6 | +* | |
| 7 | 7 | * Developer : Erwin Kooi |
| 8 | 8 | * released at : Nov 2005 |
| 9 | 9 | * last modified by : Erwin Kooi |
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | * You're free to use this code as long as you don't alter it |
| 13 | 13 | * Copyright (c) 2005 Cyane Dynamic Web Solutions |
| 14 | 14 | * Info? Mail to info@cyane.nl |
| 15 | -* | |
| 15 | +* | |
| 16 | 16 | * -------------------------------------------------------------- |
| 17 | 17 | * |
| 18 | 18 | * This class defines the data access functions to a DBF record |
| ... | ... | @@ -28,7 +28,7 @@ define ("DBFFIELD_TYPE_DATE","D"); // Date |
| 28 | 28 | define ("DBFFIELD_TYPE_LOGICAL","L"); // Logical - ? Y y N n T t F f (? when not initialized). |
| 29 | 29 | define ("DBFFIELD_TYPE_DATETIME","T"); // DateTime |
| 30 | 30 | |
| 31 | -define ("DBFFIELD_TYPE_INDEX","I"); // Index | |
| 31 | +define ("DBFFIELD_TYPE_INDEX","I"); // Index | |
| 32 | 32 | define ("DBFFIELD_IGNORE_0","0"); // ignore this field |
| 33 | 33 | |
| 34 | 34 | |
| ... | ... | @@ -40,7 +40,7 @@ class XBaseRecord { |
| 40 | 40 | var $deleted; |
| 41 | 41 | var $inserted; |
| 42 | 42 | var $recordIndex; |
| 43 | - | |
| 43 | + | |
| 44 | 44 | function XBaseRecord($table, $recordIndex, $rawData=false) { |
| 45 | 45 | $this->table =& $table; |
| 46 | 46 | $this->recordIndex=$recordIndex; |
| ... | ... | @@ -118,7 +118,7 @@ class XBaseRecord { |
| 118 | 118 | case DBFFIELD_TYPE_LOGICAL : return $this->getBoolean($columnObj); |
| 119 | 119 | case DBFFIELD_TYPE_MEMO : return $this->getMemo($columnObj); |
| 120 | 120 | case DBFFIELD_TYPE_NUMERIC : return $this->getInt($columnObj); |
| 121 | - case DBFFIELD_TYPE_INDEX : return $this->getIndex($columnObj); | |
| 121 | + case DBFFIELD_TYPE_INDEX : return $this->getIndex($columnObj); | |
| 122 | 122 | case DBFFIELD_IGNORE_0 : return false; |
| 123 | 123 | } |
| 124 | 124 | trigger_error ("cannot handle datatype".$columnObj->getType(), E_USER_ERROR); |
| ... | ... | @@ -178,13 +178,13 @@ class XBaseRecord { |
| 178 | 178 | if ($columnObj->getType()!=DBFFIELD_TYPE_INDEX) trigger_error ($columnObj->getName()." is not an Index column", E_USER_ERROR); |
| 179 | 179 | $s = $this->choppedData[$columnObj->getColIndex()]; |
| 180 | 180 | if (!$s) return false; |
| 181 | - | |
| 181 | + | |
| 182 | 182 | $ret = ord($s[0]); |
| 183 | 183 | for ($i = 1; $i < $columnObj->length; $i++) { |
| 184 | 184 | $ret += $i * 256 * ord($s[$i]); |
| 185 | 185 | } |
| 186 | - return $ret; | |
| 187 | - } | |
| 186 | + return $ret; | |
| 187 | + } | |
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * ------------------------------------------------------------------------- |
| ... | ... | @@ -265,7 +265,7 @@ class XBaseRecord { |
| 265 | 265 | case '0': |
| 266 | 266 | $this->forceSetString($columnObj,$value); |
| 267 | 267 | return; |
| 268 | - | |
| 268 | + | |
| 269 | 269 | case true: |
| 270 | 270 | $this->forceSetString($columnObj,"T"); |
| 271 | 271 | return; |
| ... | ... | @@ -294,7 +294,7 @@ class XBaseRecord { |
| 294 | 294 | } |
| 295 | 295 | $value = str_replace(",",".",$value); |
| 296 | 296 | //$this->forceSetString($columnObj,intval($value)); |
| 297 | - | |
| 297 | + | |
| 298 | 298 | /** |
| 299 | 299 | * suggestion from Sergiu Neamt: treat number values as decimals |
| 300 | 300 | **/ |
| ... | ... | @@ -309,4 +309,5 @@ class XBaseRecord { |
| 309 | 309 | function serializeRawData() { |
| 310 | 310 | return ($this->deleted?"*":" ").implode("",$this->choppedData); |
| 311 | 311 | } |
| 312 | -} | |
| 313 | 312 | \ No newline at end of file |
| 313 | +} | |
| 314 | +?> | |
| 314 | 315 | \ No newline at end of file | ... | ... |
pacotes/phpxbase/Table.class.php
| ... | ... | @@ -2,8 +2,8 @@ |
| 2 | 2 | /** |
| 3 | 3 | * ---------------------------------------------------------------- |
| 4 | 4 | * XBase |
| 5 | -* Table.class.php | |
| 6 | -* | |
| 5 | +* Table.class.php | |
| 6 | +* | |
| 7 | 7 | * Developer : Erwin Kooi |
| 8 | 8 | * released at : Nov 2005 |
| 9 | 9 | * last modified by : Erwin Kooi |
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | * You're free to use this code as long as you don't alter it |
| 13 | 13 | * Copyright (c) 2005 Cyane Dynamic Web Solutions |
| 14 | 14 | * Info? Mail to info@cyane.nl |
| 15 | -* | |
| 15 | +* | |
| 16 | 16 | * -------------------------------------------------------------- |
| 17 | 17 | * |
| 18 | 18 | * This class provides the main entry to a DBF table file. |
| ... | ... | @@ -59,9 +59,9 @@ class XBaseTable { |
| 59 | 59 | function XBaseTable($name) { |
| 60 | 60 | $this->name=$name; |
| 61 | 61 | } |
| 62 | - | |
| 62 | + | |
| 63 | 63 | function open() { |
| 64 | - | |
| 64 | + | |
| 65 | 65 | $fn = $this->name; |
| 66 | 66 | $this->isStream=strpos($this->name,"://")!==false; |
| 67 | 67 | if (!$this->isStream) { |
| ... | ... | @@ -74,9 +74,9 @@ class XBaseTable { |
| 74 | 74 | $this->fp = fopen($fn,"rb"); |
| 75 | 75 | $this->readHeader(); |
| 76 | 76 | return $this->fp!=false; |
| 77 | - | |
| 77 | + | |
| 78 | 78 | } |
| 79 | - | |
| 79 | + | |
| 80 | 80 | function readHeader() { |
| 81 | 81 | |
| 82 | 82 | $this->version = $this->readChar(); |
| ... | ... | @@ -95,7 +95,7 @@ class XBaseTable { |
| 95 | 95 | $this->readBytes(2); //reserved |
| 96 | 96 | |
| 97 | 97 | $fieldCount = ($this->headerLength - ($this->foxpro?296:33) ) / 32; |
| 98 | - | |
| 98 | + | |
| 99 | 99 | /* some checking */ |
| 100 | 100 | if (!$this->isStream && $this->headerLength>filesize($this->name)) trigger_error ($this->name." is not DBF", E_USER_ERROR); |
| 101 | 101 | if (!$this->isStream && $this->headerLength+($this->recordCount*$this->recordByteLength)-500>filesize($this->name)) trigger_error ($this->name." is not DBF", E_USER_ERROR); |
| ... | ... | @@ -200,7 +200,7 @@ class XBaseTable { |
| 200 | 200 | function getDeleteCount() { |
| 201 | 201 | return $this->deleteCount; |
| 202 | 202 | } |
| 203 | - | |
| 203 | + | |
| 204 | 204 | function toHTML($withHeader=true,$tableArgs="border='1'",$trArgs="",$tdArgs="",$thArgs="") { |
| 205 | 205 | $result = "<table $tableArgs >\n"; |
| 206 | 206 | if ($withHeader) { |
| ... | ... | @@ -262,7 +262,7 @@ class XBaseTable { |
| 262 | 262 | $result .= "</table>\n"; |
| 263 | 263 | return $result; |
| 264 | 264 | } |
| 265 | - | |
| 265 | + | |
| 266 | 266 | /** |
| 267 | 267 | * ------------------------------------------------------------------------- |
| 268 | 268 | * private functions |
| ... | ... | @@ -340,4 +340,5 @@ class XBaseTable { |
| 340 | 340 | $t = getdate($d); |
| 341 | 341 | return $this->writeShort($t["year"]) + $this->writeChar($t["mon"]) + $this->writeChar($t["mday"]); |
| 342 | 342 | } |
| 343 | -} | |
| 344 | 343 | \ No newline at end of file |
| 344 | +} | |
| 345 | +?> | |
| 345 | 346 | \ No newline at end of file | ... | ... |
pacotes/phpxbase/WritableTable.class.php
| ... | ... | @@ -2,8 +2,8 @@ |
| 2 | 2 | /** |
| 3 | 3 | * ---------------------------------------------------------------- |
| 4 | 4 | * XBase |
| 5 | -* WritableTable.class.php | |
| 6 | -* | |
| 5 | +* WritableTable.class.php | |
| 6 | +* | |
| 7 | 7 | * Developer : Erwin Kooi |
| 8 | 8 | * released at : Jan 2005 |
| 9 | 9 | * last modified by : Erwin Kooi |
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | * You're free to use this code as long as you don't alter it |
| 13 | 13 | * Copyright (c) 2005 Cyane Dynamic Web Solutions |
| 14 | 14 | * Info? Mail to info@cyane.nl |
| 15 | -* | |
| 15 | +* | |
| 16 | 16 | * -------------------------------------------------------------- |
| 17 | 17 | * |
| 18 | 18 | * This class extends the main entry to a DBF table file, with writing abilities |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | **/ |
| 22 | 22 | |
| 23 | 23 | class XBaseWritableTable extends XBaseTable { |
| 24 | - | |
| 24 | + | |
| 25 | 25 | /* static */ |
| 26 | 26 | function cloneFrom($table) { |
| 27 | 27 | $result =& new XBaseWritableTable($table->name); |
| ... | ... | @@ -56,7 +56,7 @@ class XBaseWritableTable extends XBaseTable { |
| 56 | 56 | $columns[$i]=$column; |
| 57 | 57 | $i++; |
| 58 | 58 | } |
| 59 | - | |
| 59 | + | |
| 60 | 60 | $result =& new XBaseWritableTable($filename); |
| 61 | 61 | $result->version=131; |
| 62 | 62 | $result->modifyDate=time(); |
| ... | ... | @@ -83,7 +83,7 @@ class XBaseWritableTable extends XBaseTable { |
| 83 | 83 | } |
| 84 | 84 | return $this->fp!=false; |
| 85 | 85 | } |
| 86 | - | |
| 86 | + | |
| 87 | 87 | function writeHeader() { |
| 88 | 88 | $this->headerLength=($this->foxpro?296:33) + ($this->getColumnCount()*32); |
| 89 | 89 | fseek($this->fp,0); |
| ... | ... | @@ -100,7 +100,7 @@ class XBaseWritableTable extends XBaseTable { |
| 100 | 100 | $this->writeByte($this->mdxFlag); |
| 101 | 101 | $this->writeByte($this->languageCode); |
| 102 | 102 | $this->writeBytes(str_pad("", 2,chr(0))); |
| 103 | - | |
| 103 | + | |
| 104 | 104 | foreach ($this->columns as $column) { |
| 105 | 105 | $this->writeString(str_pad(substr($column->rawname,0,11), 11,chr(0))); |
| 106 | 106 | $this->writeByte($column->type); |
| ... | ... | @@ -130,7 +130,7 @@ class XBaseWritableTable extends XBaseTable { |
| 130 | 130 | $data =& $this->record->serializeRawData(); |
| 131 | 131 | fwrite($this->fp,$data); |
| 132 | 132 | if ($this->record->inserted) $this->writeHeader(); |
| 133 | - flush($this->fp); | |
| 133 | + //flush($this->fp); | |
| 134 | 134 | } |
| 135 | 135 | function deleteRecord() { |
| 136 | 136 | $this->record->deleted=true; |
| ... | ... | @@ -163,7 +163,7 @@ class XBaseWritableTable extends XBaseTable { |
| 163 | 163 | * private functions |
| 164 | 164 | * ------------------------------------------------------------------------- |
| 165 | 165 | */ |
| 166 | - | |
| 166 | + | |
| 167 | 167 | function writeBytes($buf) { |
| 168 | 168 | return fwrite($this->fp,$buf); |
| 169 | 169 | } |
| ... | ... | @@ -197,4 +197,5 @@ class XBaseWritableTable extends XBaseTable { |
| 197 | 197 | $t = getdate($d); |
| 198 | 198 | return $this->writeShort($t["year"]) + $this->writeChar($t["mon"]) + $this->writeChar($t["mday"]); |
| 199 | 199 | } |
| 200 | -} | |
| 201 | 200 | \ No newline at end of file |
| 201 | +} | |
| 202 | +?> | |
| 202 | 203 | \ No newline at end of file | ... | ... |