Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2020
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 3.0.8.0
  8. * @ Author : DeZender
  9. * @ Release on : 25.09.2017
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class dBase
  15. {
  16. public $filename = null;
  17. public $records = array( );
  18. public $fields = array( );
  19. public $num_records = null;
  20. public $num_fields = null;
  21. public $record_length = null;
  22. public $header_length = null;
  23.  
  24. public function __construct($filename)
  25. {
  26. if (file_exists( $filename ) && ereg( 'DBF', strtoupper( $filename ) )) {
  27. $this->filename = $filename;
  28.  
  29. if ($f = fopen( $this->filename, 'r' )) {
  30. $filesize = filesize( $filename );
  31. $buf = fread( $f, $filesize );
  32. fclose( $f );
  33. }
  34. else {
  35. return false;
  36. }
  37.  
  38. if ((ord( $buf[0] ) != 3) && (ord( $buf[$filesize] ) != 26)) {
  39. return false;
  40. }
  41.  
  42. $this->num_records = array_shift( unpack( 'V', $buf[4] . $buf[5] . $buf[6] . $buf[7] ) );
  43. $this->header_length = array_shift( unpack( 'v', $buf[8] . $buf[9] ) );
  44. $this->record_length = array_shift( unpack( 'v', $buf[10] . $buf[11] ) );
  45. $this->num_fields = floor( ($this->header_length - 32) / 32 );
  46. $j = 0;
  47.  
  48. while ($j < $this->num_fields) {
  49. $off = ($j + 1) * 32;
  50. $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] );
  51. $this->fields[$j]['length'] = ord( $buf[$off + 16] );
  52. ++$j;
  53. }
  54.  
  55. $n = 0;
  56.  
  57. while ($n < $this->num_records) {
  58. $field_off = 1 + ($n * $this->record_length) + $this->header_length;
  59.  
  60. foreach ($this->fields as $f) {
  61. $this->records[$n][$f['name']] = trim( substr( $buf, $field_off, $f['length'] ) );
  62. $field_off += $f['length'];
  63. }
  64.  
  65. ++$n;
  66. }
  67.  
  68. unset( $buf );
  69. }
  70. else {
  71. return false;
  72. }
  73. }
  74.  
  75. public function getNumFields()
  76. {
  77. return $this->num_fields;
  78. }
  79.  
  80. public function getFields()
  81. {
  82. return $this->fields;
  83. }
  84.  
  85. public function getNumRecords()
  86. {
  87. return $this->num_records;
  88. .............................................................
  89. ......................................
  90. ....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement