function readHeader() { $this->version = $this->readChar(); $this->foxpro = $this->version == 48 || $this->version == 49 || $this->version == 245 || $this->version == 251; $this->modifyDate = $this->read3ByteDate(); $this->recordCount = $this->readInt(); $this->headerLength = $this->readShort(); $this->recordByteLength = $this->readShort(); $this->readBytes(2); //reserved $this->inTransaction = $this->readByte() != 0; $this->encrypted = $this->readByte() != 0; $this->readBytes(4); //Free record thread $this->readBytes(8); //Reserved for multi-user dBASE $this->mdxFlag = $this->readByte(); $this->languageCode = $this->readByte(); $this->readBytes(2); //reserved $fieldCount = ($this->headerLength - ($this->foxpro ? 296 : 33)) / 32; /* some checking */ if (!$this->isStream && $this->headerLength > filesize($this->name)) { trigger_error($this->name . " is not DBF", E_USER_ERROR); } if (!$this->isStream && $this->headerLength + $this->recordCount * $this->recordByteLength - 500 > filesize($this->name)) { trigger_error($this->name . " is not DBF", E_USER_ERROR); } /* columns */ $this->columnNames = array(); $this->columns = array(); $bytepos = 1; for ($i = 0; $i < $fieldCount; $i++) { $column = new XBaseColumn($this->readString(11), $this->readByte(), $this->readInt(), $this->readChar(), $this->readChar(), $this->readBytes(2), $this->readChar(), $this->readBytes(2), $this->readByte() != 0, $this->readBytes(7), $this->readByte() != 0, $i, $bytepos); $bytepos += $column->getLength(); $this->columnNames[$i] = $column->getName(); $this->columns[$i] = $column; } /**/ if ($this->foxpro) { $this->backlist = $this->readBytes(263); } $b = $this->readByte(); $this->recordPos = -1; $this->record = false; $this->deleteCount = 0; }