You are here

private function PHPExcel_Reader_Excel5::_readRecordData in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php \PHPExcel_Reader_Excel5::_readRecordData()

* Read record data from stream, decrypting as required * *

Parameters

string $data Data stream to read from: * @param int $pos Position to start reading from * @param int $length Record data length * * @return string Record data

64 calls to PHPExcel_Reader_Excel5::_readRecordData()
PHPExcel_Reader_Excel5::listWorksheetInfo in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * *
PHPExcel_Reader_Excel5::_getSplicedRecordData in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php
* Reads a record from current position in data stream and continues reading data as long as CONTINUE * records are found. Splices the record data pieces and returns the combined string as if record data * is in one piece. * Moves to next current…
PHPExcel_Reader_Excel5::_readBlank in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php
* Read BLANK record
PHPExcel_Reader_Excel5::_readBoolErr in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php
* Read BOOLERR record * This record represents a Boolean value or error value * cell. * * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format"
PHPExcel_Reader_Excel5::_readBottomMargin in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php
* Read BOTTOMMARGIN record

... See full list

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php, line 1106

Class

PHPExcel_Reader_Excel5
PHPExcel_Reader_Excel5

Code

private function _readRecordData($data, $pos, $len) {
  $data = substr($data, $pos, $len);

  // File not encrypted, or record before encryption start point
  if ($this->_encryption == self::MS_BIFF_CRYPTO_NONE || $pos < $this->_encryptionStartPos) {
    return $data;
  }
  $recordData = '';
  if ($this->_encryption == self::MS_BIFF_CRYPTO_RC4) {
    $oldBlock = floor($this->_rc4Pos / self::REKEY_BLOCK);
    $block = floor($pos / self::REKEY_BLOCK);
    $endBlock = floor(($pos + $len) / self::REKEY_BLOCK);

    // Spin an RC4 decryptor to the right spot. If we have a decryptor sitting
    // at a point earlier in the current block, re-use it as we can save some time.
    if ($block != $oldBlock || $pos < $this->_rc4Pos || !$this->_rc4Key) {
      $this->_rc4Key = $this
        ->_makeKey($block, $this->_md5Ctxt);
      $step = $pos % self::REKEY_BLOCK;
    }
    else {
      $step = $pos - $this->_rc4Pos;
    }
    $this->_rc4Key
      ->RC4(str_repeat("\0", $step));

    // Decrypt record data (re-keying at the end of every block)
    while ($block != $endBlock) {
      $step = self::REKEY_BLOCK - $pos % self::REKEY_BLOCK;
      $recordData .= $this->_rc4Key
        ->RC4(substr($data, 0, $step));
      $data = substr($data, $step);
      $pos += $step;
      $len -= $step;
      $block++;
      $this->_rc4Key = $this
        ->_makeKey($block, $this->_md5Ctxt);
    }
    $recordData .= $this->_rc4Key
      ->RC4(substr($data, 0, $len));

    // Keep track of the position of this decryptor.
    // We'll try and re-use it later if we can to speed things up
    $this->_rc4Pos = $pos + $len;
  }
  elseif ($this->_encryption == self::MS_BIFF_CRYPTO_XOR) {
    throw new PHPExcel_Reader_Exception('XOr encryption not supported');
  }
  return $recordData;
}