You are here

function PclZip::properties in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/lib/pclzip/pclzip.lib.php \PclZip::properties()

File

includes/moodle/lib/pclzip/pclzip.lib.php, line 1090

Class

PclZip

Code

function properties() {

  //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");

  // ----- Reset the error handler
  $this
    ->privErrorReset();

  // ----- Magic quotes trick
  $this
    ->privDisableMagicQuotes();

  // ----- Check archive
  if (!$this
    ->privCheckFormat()) {
    $this
      ->privSwapBackMagicQuotes();

    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
    return 0;
  }

  // ----- Default properties
  $v_prop = array();
  $v_prop['comment'] = '';
  $v_prop['nb'] = 0;
  $v_prop['status'] = 'not_exist';

  // ----- Look if file exists
  if (@is_file($this->zipname)) {

    // ----- Open the zip file

    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
    if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) {
      $this
        ->privSwapBackMagicQuotes();

      // ----- Error log
      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in binary read mode');

      // ----- Return

      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);
      return 0;
    }

    // ----- Read the central directory informations
    $v_central_dir = array();
    if (($v_result = $this
      ->privReadEndCentralDir($v_central_dir)) != 1) {
      $this
        ->privSwapBackMagicQuotes();

      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
      return 0;
    }

    // ----- Close the zip file
    $this
      ->privCloseFd();

    // ----- Set the user attributes
    $v_prop['comment'] = $v_central_dir['comment'];
    $v_prop['nb'] = $v_central_dir['entries'];
    $v_prop['status'] = 'ok';
  }

  // ----- Magic quotes trick
  $this
    ->privSwapBackMagicQuotes();

  // ----- Return

  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);
  return $v_prop;
}