Commit e8f17d64738e596165790d839f1a08d5872c6fb6

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