Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 3.0.8.0
- * @ Author : DeZender
- * @ Release on : 25.09.2017
- * @ Official site : http://DeZender.Net
- *
- */
- class dBase
- {
- public $filename = null;
- public $records = array( );
- public $fields = array( );
- public $num_records = null;
- public $num_fields = null;
- public $record_length = null;
- public $header_length = null;
- public function __construct($filename)
- {
- if (file_exists( $filename ) && ereg( 'DBF', strtoupper( $filename ) )) {
- $this->filename = $filename;
- if ($f = fopen( $this->filename, 'r' )) {
- $filesize = filesize( $filename );
- $buf = fread( $f, $filesize );
- fclose( $f );
- }
- else {
- return false;
- }
- if ((ord( $buf[0] ) != 3) && (ord( $buf[$filesize] ) != 26)) {
- return false;
- }
- $this->num_records = array_shift( unpack( 'V', $buf[4] . $buf[5] . $buf[6] . $buf[7] ) );
- $this->header_length = array_shift( unpack( 'v', $buf[8] . $buf[9] ) );
- $this->record_length = array_shift( unpack( 'v', $buf[10] . $buf[11] ) );
- $this->num_fields = floor( ($this->header_length - 32) / 32 );
- $j = 0;
- while ($j < $this->num_fields) {
- $off = ($j + 1) * 32;
- $this->fields[$j]['name'] = trim( $buf[$off] . $buf[$off + 1] . $buf[$off + 2] . $buf[$off + 3] . $buf[$off + 4] . $buf[$off + 5] . $buf[$off + 6] . $buf[$off + 7] . $buf[$off + 8] . $buf[$off + 9] );
- $this->fields[$j]['length'] = ord( $buf[$off + 16] );
- ++$j;
- }
- $n = 0;
- while ($n < $this->num_records) {
- $field_off = 1 + ($n * $this->record_length) + $this->header_length;
- foreach ($this->fields as $f) {
- $this->records[$n][$f['name']] = trim( substr( $buf, $field_off, $f['length'] ) );
- $field_off += $f['length'];
- }
- ++$n;
- }
- unset( $buf );
- }
- else {
- return false;
- }
- }
- public function getNumFields()
- {
- return $this->num_fields;
- }
- public function getFields()
- {
- return $this->fields;
- }
- public function getNumRecords()
- {
- return $this->num_records;
- .............................................................
- ......................................
- ....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement