コード例 #1
0
 /**
  * em_unzip::_check_parameters()
  *
  * { Description }
  *
  * @param integer $p_error_code
  * @param string $p_error_string
  */
 function _check_parameters(&$p_params, $p_default)
 {
     // Check that param is an array
     if (!is_array($p_params)) {
         $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, 'Unsupported parameter, waiting for an array');
         return em_unzip::errorCode();
     }
     // Check that all the params are valid
     for (reset($p_params); list($v_key, $v_value) = each($p_params);) {
         if (!isset($p_default[$v_key])) {
             $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, 'Unsupported parameter with key \'' . $v_key . '\'');
             return em_unzip::errorCode();
         }
     }
     // Set the default values
     for (reset($p_default); list($v_key, $v_value) = each($p_default);) {
         if (!isset($p_params[$v_key])) {
             $p_params[$v_key] = $p_default[$v_key];
         }
     }
     // Check specific parameters
     $v_callback_list = array('callback_pre_add', 'callback_post_add', 'callback_pre_extract', 'callback_post_extract');
     for ($i = 0; $i < sizeof($v_callback_list); $i++) {
         $v_key = $v_callback_list[$i];
         if (isset($p_params[$v_key]) && $p_params[$v_key] != '') {
             if (!function_exists($p_params[$v_key])) {
                 $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE, "Callback '" . $p_params[$v_key] . "()' is not an existing function for " . "parameter '" . $v_key . "'");
                 return em_unzip::errorCode();
             }
         }
     }
     return 1;
 }
コード例 #2
0
 /**
  * Unzips a zip file in the given path.
  *
  * Uses unzip binary if available, otherwise a pure PHP unzip is used.
  *
  * @param string $file		Full path to zip file
  * @param string $path		Path to change to before extracting
  * @return boolean	True on success, false in failure
  */
 function unzip($file, $path)
 {
     if (strlen($GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'])) {
         chdir($path);
         $cmd = $GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'] . ' -o ' . escapeshellarg($file);
         exec($cmd, $list, $ret);
         return $ret === 0;
     } else {
         // we use a pure PHP unzip
         $unzip = new em_unzip($file);
         $ret = $unzip->extract(array('add_path' => $path));
         return is_array($ret);
     }
 }