当前位置: 首页>>代码示例>>PHP>>正文


PHP PclZip::extractByIndex方法代码示例

本文整理汇总了PHP中PclZip::extractByIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP PclZip::extractByIndex方法的具体用法?PHP PclZip::extractByIndex怎么用?PHP PclZip::extractByIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PclZip的用法示例。


在下文中一共展示了PclZip::extractByIndex方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: extractTo

 public function extractTo($Path, $Names)
 {
     $Indexes = array();
     // Convert the name(s) to indexes.
     foreach ((array) $Names as $Name) {
         if (!isset($this->_Names[$Name])) {
             continue;
         }
         $Indexes[] = $this->_Names[$Name]['index'];
     }
     $IndexesStr = implode(',', $Indexes);
     $Result = $this->PclZip->extractByIndex($IndexesStr, $Path);
     return $Result != 0;
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:14,代码来源:class.pclzipadapter.php

示例2: parse

 function parse()
 {
     $temp_file = new upload($this->_filename, DIR_FS_CACHE);
     if ($temp_file->exists() && $temp_file->parse() && $temp_file->save()) {
         $this->_filename = $temp_file;
     }
     if ($this->_compression_type == 'zip') {
         require_once '../ext/zip/pclzip.lib.php';
         $archive = new PclZip($this->_filename->destination . $this->_filename->filename);
         if ($archive->extract(PCLZIP_OPT_PATH, DIR_FS_CACHE) == 0) {
             return false;
         } else {
             $file = $archive->extractByIndex(0);
             @unlink($this->_filename->destination . $this->_filename->filename);
             $this->_filename = DIR_FS_CACHE . $file[0]['stored_filename'];
         }
     } else {
         $this->_filename = $this->_filename->destination . $this->_filename->filename;
     }
     switch ($this->_file_type) {
         case 'csv':
             return $this->parseCsvFile();
         case 'xml':
             return $this->parseXmlFile();
     }
 }
开发者ID:4DvAnCeBoY,项目名称:tomatocart-shoppingcart,代码行数:26,代码来源:importer.php

示例3: execute

 protected function execute()
 {
     $this->loadParams();
     $archive = new PclZip($this->zipFile->getFileName());
     $listContent = $archive->listContent();
     $allFilesCount = count($listContent);
     $processedFiles = -self::UNZIP_STEP;
     while ($processedFiles < $allFilesCount) {
         $processedFiles += self::UNZIP_STEP;
         if ($this->isDone($processedFiles, $this->_('%s%% files unzipped', round($processedFiles / $allFilesCount * 100, 0)))) {
             continue;
         }
         $this->changePermissions($archive->extractByIndex($processedFiles . '-' . ($processedFiles + self::UNZIP_STEP - 1), $this->outputDirectory->getFileName()));
         $this->setDone($processedFiles);
     }
 }
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:16,代码来源:UnzipFileTask.class.php

示例4: error

     }
     if ($my_uploader->upload_failed()) {
         array_push($inserterrors, $my_uploader->get_error());
     }
     if (count($inserterrors) > 0) {
         error('admin.php?action=db&job=query', $inserterrors);
     } else {
         $ext = get_extension($file);
         if (($ext == 'zip' || $ext == 'sql') && file_exists($file)) {
             if ($ext == 'zip') {
                 require_once 'classes/class.zip.php';
                 $archive = new PclZip($file);
                 if (($list = $archive->listContent()) == 0) {
                     error($archive->errorInfo(true));
                 }
                 $data = $archive->extractByIndex($list[0]['index'], PCLZIP_OPT_EXTRACT_AS_STRING);
                 $lines = $data[0]['content'];
                 unset($data);
             } elseif ($ext == 'sql') {
                 $lines = file_get_contents($file);
             }
         }
     }
 } else {
     $lines = $gpc->get('query', none);
 }
 $sql = str_replace('{:=DBPREFIX=:}', $db->pre, $lines);
 @exec_query_form($lines);
 $hl = highlight_sql_query($sql);
 if (!empty($lines)) {
     ob_start();
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:31,代码来源:db.php

示例5: PclZip

 /**
  * @param $galleryId
  * @param $file
  * @param $user
  * @return bool|int
  */
 function process_batch_image_upload($galleryId, $file, $user)
 {
     global $prefs;
     $numimages = 0;
     include_once 'vendor_extra/pclzip/pclzip.lib.php';
     $archive = new PclZip($file);
     // Read Archive contents
     $ziplist = $archive->listContent();
     if (!$ziplist) {
         return false;
     }
     // Archive invalid
     foreach ($ziplist as $zipfile) {
         $file = $zipfile["filename"];
         if (!$zipfile["folder"]) {
             //copied
             $gal_info = $this->get_gallery($galleryId);
             $upl = 1;
             if (!empty($prefs['gal_match_regex'])) {
                 if (!preg_match('/' . $prefs['gal_match_regex'] . '/', $file, $reqs)) {
                     $upl = 0;
                 }
             }
             if (!empty($prefs['gal_nmatch_regex'])) {
                 if (preg_match('/' . $prefs['gal_nmatch_regex'] . '/', $file, $reqs)) {
                     $upl = 0;
                 }
             }
             //extract file
             $archive->extractByIndex($zipfile["index"], $prefs['tmpDir'], dirname($file));
             //extract and remove (dangerous) pathname
             $file = basename($file);
             //unset variables
             unset($this->filetype);
             unset($this->xsize);
             unset($this->ysize);
             //determine filetype and dimensions
             $this->getfileinfo($prefs['tmpDir'] . "/" . $file);
             $foo = explode(".", $file);
             $exp = end($foo);
             // read image and delete it after
             $this->readimagefromfile($prefs['tmpDir'] . "/" . $file);
             unlink($prefs['tmpDir'] . "/" . $file);
             if ($this->issupported($exp)) {
                 // convert to handle
                 $this->readimagefromstring();
                 if ($this->validhandle()) {
                     $this->getimageinfo();
                 }
             }
             //if there is no mimetype, we don't got a image
             if (isset($this->filetype)) {
                 if (!isset($this->xsize)) {
                     $this->xsize = $this->ysize = 0;
                 }
                 $imageId = $this->insert_image($galleryId, $file, '', $file, $this->filetype, $this->image, $this->filesize, $this->xsize, $this->ysize, $user, '', '', NULL, NULL, $gal_info);
                 $numimages++;
             }
         }
     }
     return $numimages;
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:68,代码来源:imagegallib.php

示例6: switch

 function upload_zip($imagefile)
 {
     if (!mkdir($tmpdir = $this->config->pathto_cache . '/' . uniqid("ps"))) {
         $this->last_error = "Your cache directory is not writeable, please check the permissions.";
         return false;
     }
     $archive = $imagefile["tmp_name"];
     if (!is_uploaded_file($archive)) {
         $this->last_error = "Could not upload file";
         return false;
     }
     switch ($this->config->unzip_method) {
         case 'unzip':
             //decompress archive to temp
             $cmd = escapeshellcmd($this->config->pathto_unzip);
             $cmd .= ' -d "' . escapeshellcmd(realpath($tmpdir));
             $cmd .= '" "' . escapeshellcmd(realpath($archive)) . '"';
             if (!exec($cmd)) {
                 $this->last_error = "Could not decompress archive";
                 return false;
             }
             break;
         case 'pclzip':
             /* 
             				This uses the PclZip Library to extract the files of the zip-archive
             */
             $zip = new PclZip(realpath($archive));
             $archiveContents = $zip->listContent();
             foreach ($archiveContents as $file) {
                 if (preg_match("/\\.(" . $this->config->recognised_extensions . ")\$/i", $file['filename'])) {
                     //if(stristr($file['filename'],'/') === FALSE){
                     $imageIndex .= $file['index'] . ",";
                     //}
                 }
             }
             $imageIndex = substr($imageIndex, 0, strlen($imageIndex) - 1);
             $zip->extractByIndex($imageIndex, $tmpdir);
             break;
     }
     //start processing archive contents
     $wd = $tmpdir;
     $contents = $this->get_listing($wd, "images");
     //cope with archives contained within a directory
     if (empty($contents->files) && count($contents->dirs) == 1) {
         $contents = $this->get_listing($wd .= '/' . $contents->dirs[0], "images");
     }
     $success = true;
     //add any images to current gallery
     foreach ($contents->files as $image) {
         //make sure file has a recognised extension
         if (!preg_match("/\\.(" . $this->config->recognised_extensions . ")\$/i", $image)) {
             $image .= ".jpeg";
         }
         $path = $this->config->pathto_galleries . $this->gallery->id . "/" . $image;
         $srcImage = $image;
         if (file_exists($path)) {
             switch ($this->config->upload_overwrite) {
                 case 1:
                     //overwrite
                     $this->delete_image($image);
                     break;
                 case 2:
                     //generate unique
                     for ($i = 0; file_exists($path); $i++) {
                         $pivot = strrpos($srcImage, ".");
                         $image = substr($srcImage, 0, $pivot) . '-' . $i . substr($srcImage, $pivot, strlen($srcImage) - $pivot);
                         $path = $this->config->pathto_galleries . $this->gallery->id . "/" . $image;
                     }
                     break;
                 case 0:
                     //raise error
                 //raise error
                 default:
                     $this->last_error = "File already exists";
                     $success = false;
                     continue;
             }
         }
         copy($wd . '/' . $srcImage, $path);
         @chmod($path, octdec($this->config->chmod_value));
         $img = new image();
         $img->filename = $image;
         $img->name = strtr(substr($image, strrpos($image, "/"), strrpos($image, ".") - strlen($image)), "_", " ");
         list($img->width, $img->height, $img->type) = GetImageSize($path);
         $this->gallery->images[count($this->gallery->images)] = $img;
     }
     //add any directories as subgalleries, if allowed
     foreach ($contents->dirs as $gallery) {
         if ($gallery != '__MACOSX') {
             $path = $this->config->pathto_galleries . $this->gallery->id . "/" . $gallery;
             if (file_exists($path)) {
                 switch ($this->config->upload_overwrite) {
                     case 1:
                         //overwrite
                         $this->delete_gallery($this->gallery->id . '/' . $gallery);
                         break;
                     case 2:
                         //generate unique
                         for ($i = 0; file_exists($path); $i++) {
                             $path = $this->config->pathto_galleries . $this->gallery->id . "/" . $gallery . '-' . $i;
//.........这里部分代码省略.........
开发者ID:noeljackson,项目名称:PhotoStack,代码行数:101,代码来源:admin.class.php

示例7: PclZip

    }
    if (!$error) {
        $db = @mysql_select_db($_GET['dbn']);
    }
    if (!$db) {
        $error = C_WRONG_DB . " (" . $_GET['dbn'] . ")";
    }
}
// open the file
if (!$error && !isset($firstSession)) {
    // gzopen can be used for plain text too!
    // extract zip file
    if (PMBP_file_info("comp", $_GET["fn"]) == "zip") {
        include_once "pclzip.lib.php";
        $pclzip = new PclZip($_GET["fn"]);
        $extracted_file = $pclzip->extractByIndex(0, PMBP_EXPORT_DIR, "");
        if ($pclzip->error_code != 0) {
            $error = "plczip: " . $pclzip->error_string . "<br>" . BI_BROKEN_ZIP . "!";
        }
        $_GET["fn"] = substr($_GET["fn"], 0, strlen($_GET["fn"]) - 4);
        unset($pclzip);
    }
    if (!$error && !($file = @gzopen($_GET["fn"], "r"))) {
        $error = C_OPEN . " " . $_GET["fn"];
    }
}
if (!$error) {
    // get start time to calculate duration
    if (function_exists("microtime")) {
        $microtime = explode(" ", microtime());
        $starttime = $microtime[0] + $microtime[1];
开发者ID:wilderguzman,项目名称:lugrawibe,代码行数:31,代码来源:big_import.php

示例8: dirname

 function process_zip_pclzip($filename)
 {
     require_once dirname(__FILE__) . '/pclzip.lib.php';
     $added = array();
     $existing = $this->user->images;
     $zip = new PclZip($filename);
     if ($zip) {
         $list = $zip->listContent();
         if ($list) {
             $temp_dir = $this->makeTempDir();
             // for each entry
             foreach ($list as $entry) {
                 if (!$entry['folder']) {
                     // get the name
                     $name = $entry['filename'];
                     // if the name is jpg/gif/png
                     if (preg_match('#([^/\\\\]+)\\.(jpg|gif|png)$#i', $name, $matches)) {
                         $oname = $matches[1] . '.' . $matches[2];
                         $filesize = $entry['size'];
                         if ($this->filesizeOK($filesize)) {
                             $newname = $temp_dir . $oname;
                             // extract the file to the temp name
                             $result = $zip->extractByIndex($entry['index'], PCLZIP_OPT_PATH, $temp_dir, PCLZIP_OPT_REMOVE_ALL_PATH);
                             if ($result) {
                                 /* debugging, hopefully no longer needed
                                                                    if( $this->app->config->debug_imagick ) {
                                 
                                                                         echo '<hr />Debug: Extracted file should be: ',$newname,"\n<pre>";
                                                                         print_r($result);
                                                                         echo '</pre>',"\n";
                                                                         echo (file_exists($newname) ? ' File Extracted ' : ' File not extracted ');
                                                                     }
                                 */
                                 // add the image
                                 $iid = $this->images->addimage($oname, $this->user->user_id, $newname, $this->gallery, 0, $this->public);
                                 // delete the temp file
                                 unlink($newname);
                                 if (!$iid) {
                                     $this->errors = array_merge($this->errors, $this->images->errors);
                                     $this->images->errors = array();
                                 } else {
                                     $added[] = $iid;
                                     $existing++;
                                 }
                             } else {
                                 $this->errors[] = $this->app->translate('Unable to read from zip archive');
                             }
                         } else {
                             $this->errors[] = htmlspecialchars($name) . ': ' . $this->app->translate('file too large.');
                         }
                     } elseif ($name[strlen($name) - 1] != '/') {
                         $this->errors[] = htmlspecialchars($name) . ': ' . $this->app->translate('Unknown file format');
                     }
                 }
             }
             //                rmdir($temp_dir);
         } else {
             $this->errors[] = $this->app->translate('Unable to read from zip archive');
         }
     } else {
         $this->errors[] = $this->app->translate('Unable to read from zip archive');
     }
     return $added;
 }
开发者ID:akirafreak,项目名称:php-image-host,代码行数:64,代码来源:ziphelper.class.php

示例9: PclZip

 /**
  * use the pclZip lib to list the contents of the file
  *
  * the following files can be acquired and used to trace errors if necessary
  * require_once( MAX_PATH . '/lib/pclzip/pclerror.lib.php' );
  * require_once( MAX_PATH . '/lib/pclzip/pcltrace.lib.php' );
  * require_once( MAX_PATH . '/lib/pclzip/pcltar.lib.php' );
  *
  *
  * @param string $pkgFileUploaded
  * @param string $zipFile
  * @param boolean $overwrite
  * @return boolean
  */
 function _checkPackageContents($pkgFileUploaded, $zipFile, $overwrite = false)
 {
     //OA::logMem('enter _checkPackageContents');
     if (!file_exists($zipFile)) {
         $this->_logError('File not found ' . $zipFile);
         return false;
     }
     $this->_logMessage('starting _checkPackageContents ' . $pkgFileUploaded);
     $aExpectedPackage = $this->_parsePackageFilename($pkgFileUploaded);
     $pkgFile = $aExpectedPackage['name'] . '.xml';
     $this->_logMessage('expecting definition ' . $pkgFile);
     require_once MAX_PATH . '/lib/pclzip/pclzip.lib.php';
     $oZip = new PclZip($zipFile);
     $aContents = $oZip->listContent();
     if (!$aContents) {
         $this->_logError('Failed to read contents of zip file ' . $zipFile);
         return false;
     }
     $aConf = $GLOBALS['_MAX']['CONF'];
     $pattPluginDefFile = '/' . preg_quote($aConf['pluginPaths']['packages'], '/') . '[\\w\\d]+\\.xml/';
     $pattGroupDefFile = '/' . preg_quote($aConf['pluginPaths']['packages'], '/') . '[\\w\\d]+\\/[\\w\\d]+\\.xml/';
     // find all of the xml definition files and compile a smiple array of files that are stored in the zipfile (exclude folders)
     foreach ($aContents as $i => &$aItem) {
         $aPath = pathinfo($aItem['filename']);
         $file = '/' . $aItem['filename'];
         if ($aItem['folder']) {
             continue;
         }
         if (!$aPkgFile && preg_match($pattPluginDefFile, $file, $aMatches)) {
             $this->_logMessage('detected plugin definition file ' . $file);
             $aPkgFile['pathinfo'] = $aPath;
             $aPkgFile['storedinfo'] = $aItem;
             $aFilesStored[] = $file;
             continue;
         }
         if (preg_match($pattGroupDefFile, $file, $aMatches)) {
             $this->_logMessage('detected group definition file ' . $file);
             $aXMLFiles[$aPath['basename']]['pathinfo'] = $aPath;
             $aXMLFiles[$aPath['basename']]['storedinfo'] = $aItem;
             $aFilesStored[] = $file;
             continue;
         }
         if (strpos($aPath['dirname'], '/etc/changes') == 0) {
             $aFilesStored[] = $file;
             continue;
         }
     }
     // must have a plugin package definition file
     if (!$aPkgFile) {
         $this->_logError('Plugin definition ' . $aExpectedPackage['name'] . '.xml not found in uploaded file: ' . $pkgFileUploaded);
         $this->errcode = OX_PLUGIN_ERROR_PACKAGE_DEFINITION_NOT_FOUND;
         return false;
     }
     // extract the plugin package definition file to var/tmp folder
     $aResult = $oZip->extractByIndex($aPkgFile['storedinfo']['index'], PCLZIP_OPT_ADD_PATH, $this->basePath . '/var/tmp', PCLZIP_OPT_SET_CHMOD, OX_PLUGIN_DIR_WRITE_MODE, PCLZIP_OPT_REPLACE_NEWER);
     if (!is_array($aResult) || $aResult[0]['status'] != 'ok') {
         $this->_logError('Error extracting plugin definition file: ' . $aResult[0]['status'] . ' : ' . $aResult[0]['stored_filename']);
         $this->errcode = OX_PLUGIN_ERROR_PACKAGE_EXTRACT_FAILED;
         return false;
     }
     // parse the plugin package definition file
     $pathPackages = '/var/tmp' . $this->pathPackages;
     if (!$this->_parsePackage($this->basePath . $pathPackages . $pkgFile)) {
         $this->_logError('Failed to parse the plugin definition ' . $pkgFile);
         $this->errcode = OX_PLUGIN_ERROR_PACKAGE_PARSE_FAILED;
         @unlink($this->basePath . $pathPackages . $pkgFile);
         return false;
     }
     $aPackage =& $this->aParse['package'];
     @unlink($this->basePath . $pathPackages . $pkgFile);
     // check that plugin is not already installed
     if (!$overwrite && array_key_exists($aPackage['name'], $GLOBALS['_MAX']['CONF']['plugins'])) {
         $this->_logError('Plugin with this name is already installed ' . $aPackage['name']);
         $this->errcode = OX_PLUGIN_ERROR_PACKAGE_NAME_EXISTS;
         return false;
     }
     // ensure the plugin package definition file has a valid version number
     if (empty($aPackage['version'])) {
         $this->_logError('Failed to retrieve version from the plugin definition ' . $pkgFile);
         $this->errcode = OX_PLUGIN_ERROR_PACKAGE_VERSION_NOT_FOUND;
         return false;
     }
     if ($aExpectedPackage['version'] && $aExpectedPackage['version'] != $aPackage['version']) {
         $this->_logError('Version found ' . $aPackage['version'] . ' is not that expected ' . $aExpectedPackage['version']);
         $this->errcode = OX_PLUGIN_ERROR_PACKAGE_VERSION_NOT_FOUND;
         return false;
//.........这里部分代码省略.........
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:101,代码来源:PluginManager.php

示例10: elseif

     if (!$listFiles[$i]['folder'] and trim($listFiles[$i]['filename']) == 'config.ini') {
         $iniIndex = $i;
         break;
     }
 }
 // Loi khong co file cau hinh
 if ($iniIndex == -1) {
     $error = $lang_module['autoinstall_error_missing_cfg'];
 } else {
     // Giai nen file config de doc thong tin
     $temp_extract_dir = NV_TEMP_DIR;
     // Xoa file config neu ton tai
     if (file_exists(NV_ROOTDIR . '/' . $temp_extract_dir . '/config.ini')) {
         @nv_deletefile(NV_ROOTDIR . '/' . $temp_extract_dir . '/config.ini');
     }
     $extract = $zip->extractByIndex($iniIndex, PCLZIP_OPT_PATH, NV_ROOTDIR . '/' . $temp_extract_dir);
     if (empty($extract) or !isset($extract[0]['status']) or $extract[0]['status'] != 'ok' or !file_exists(NV_ROOTDIR . '/' . $temp_extract_dir . '/config.ini')) {
         $error = $lang_module['autoinstall_cantunzip'];
     } else {
         // Doc, kiem tra thong tin file config.ini
         $extConfig = nv_parse_ini_file(NV_ROOTDIR . '/' . $temp_extract_dir . '/config.ini', true);
         $extConfigCheck = nv_check_ext_config_filecontent($extConfig);
         if (!$extConfigCheck) {
             $error = $lang_module['autoinstall_error_cfg_content'];
         } elseif (!in_array($extConfig['extension']['type'], $arraySysOption['allowExtType'])) {
             $error = $lang_module['autoinstall_error_cfg_type'];
         } elseif (!preg_match($global_config['check_version'], $extConfig['extension']['version'])) {
             $error = $lang_module['autoinstall_error_cfg_version'];
         } elseif (is_array($arraySysOption['checkName'][$extConfig['extension']['type']])) {
             foreach ($arraySysOption['checkName'][$extConfig['extension']['type']] as $check) {
                 if (!preg_match($check, $extConfig['extension']['name'])) {
开发者ID:lzhao18,项目名称:nukeviet,代码行数:31,代码来源:upload.php

示例11: spip_deballe_paquet

function spip_deballe_paquet($paquet, $fichier, $dest, $range) {
	global $chmod;

	// le repertoire temporaire est invariant pour permettre la reprise
	@mkdir($tmp = _DIR_BASE.'zip_'.md5($fichier), $chmod);
	$ok = is_dir($tmp);

	$zip = new PclZip($fichier);
	$content = $zip->listContent();
	$max_index = count($content);
	$start_index = isset($_REQUEST['start']) ? intval($_REQUEST['start']) : 0;

	if ($start_index < $max_index) {
		if (!$range) {
			$range = _PCL_ZIP_RANGE;
		}
		$end_index = min($start_index + $range, $max_index);
		$ok &= $zip->extractByIndex(
			"$start_index-$end_index",
			PCLZIP_OPT_PATH,
			$tmp,
			PCLZIP_OPT_SET_CHMOD,
			$chmod,
			PCLZIP_OPT_REPLACE_NEWER,
			PCLZIP_OPT_REMOVE_PATH,
			_REMOVE_PATH_ZIP."/",
			PCLZIP_CB_POST_EXTRACT,
			'touchCallBack'
		);
	}

	if (!$ok or $zip->error_code < 0) {
		debut_html();
		echo _TT('tradloader:donnees_incorrectes', array('erreur' => $zip->errorInfo()));
		fin_html();
	} else {
		// si l'extraction n'est pas finie, relancer
		if ($start_index < $max_index) {

			$url = _DIR_BASE._SPIP_LOADER_SCRIPT
			.  (strpos(_SPIP_LOADER_SCRIPT, '?') ? '&' : '?')
			. "etape=fichier&chemin=$paquet&dest=$dest&start=$end_index";
			$progres = $start_index/$max_index;
			spip_redirige_boucle($url, $progres);
		}

		if ($dest) {
			@mkdir(_DIR_PLUGINS, $chmod);
			$dir = _DIR_PLUGINS . $dest;
			$url = _DIR_BASE._SPIP_LOADER_PLUGIN_RETOUR;
		} else {
			$dir =  _DIR_BASE;
			$url = _DIR_BASE._SPIP_LOADER_URL_RETOUR;
		}
		move_all($tmp, $dir);
		rmdir($tmp);
		nettoyer_racine($fichier);
		header("Location: $url");
	}
}
开发者ID:samszo,项目名称:open-edition,代码行数:60,代码来源:spip_loader.php

示例12: unzipConversionResults

 function unzipConversionResults($sourceZipPath, $previewDirectory)
 {
     chmod($previewDirectory, 0700);
     $destinationZipPath = $previewDirectory . DIRECTORY_SEPARATOR . basename($sourceZipPath);
     $this->destinationZip = $destinationZipPath;
     if (!moveFile($sourceZipPath, $destinationZipPath)) {
         webServiceError('&error-webpage-unable-to-move;', 500, array('source' => $sourceZipPath, 'destination' => $destinationZipPath));
     }
     chmod($destinationZipPath, 0666);
     include_once dirname(__FILE__) . '/lib/pclzip-2-6/pclzip.lib.php';
     $archive = new PclZip($destinationZipPath);
     if (($archivedFiles = $archive->listContent()) == 0) {
         webServiceError('&error-webpage-unzipping-files;', 500, array('errorMessage' => $archive->errorInfo(true)));
     }
     foreach ($archivedFiles as $archivedFile) {
         $extractedFileMetaData = $archive->extractByIndex($archivedFile['index'], PCLZIP_OPT_PATH, $previewDirectory);
         $extractedFileMetaData = $extractedFileMetaData[0];
         $extractedDestinationPath = substr($extractedFileMetaData['filename'], 2);
         if (file_exists($extractedDestinationPath) && !chmod($extractedDestinationPath, 0700)) {
             webServiceError('&error-webpage-unzipping-files;', 500, array('errorMessage' => $extractedDestinationPath));
         }
     }
     return $this->destinationZip;
 }
开发者ID:Nolfneo,项目名称:docvert,代码行数:24,代码来源:webpage.php

示例13: extractUsefulOasisOpenDocumentFiles

/**
 * gets the useful stuff from an Oasis OpenDocument archive
 */
function extractUsefulOasisOpenDocumentFiles($oasisOpenDocumentPath)
{
    if (!trim($oasisOpenDocumentPath)) {
        webServiceError('&error-oasis-path;');
    }
    ini_set('include_path', ini_get('include_path') . ':' . DOCVERT_DIR . 'core/lib/pclzip-2-6:');
    include_once dirname(__FILE__) . '/lib/pclzip-2-6/pclzip.lib.php';
    $unknownImageIndex = 1;
    $documentDirectory = dirname($oasisOpenDocumentPath) . DIRECTORY_SEPARATOR;
    $archive = new PclZip($oasisOpenDocumentPath);
    $odfObjects = array();
    if (($archivedFiles = $archive->listContent()) == 0) {
        webServiceError('&error-unzipping-archive; ' . revealXml($archive->errorInfo(true)));
    }
    foreach ($archivedFiles as $archivedFile) {
        if (isAnOasisOpenDocumentFileWeWant($archivedFile['filename'])) {
            $archive->extractByIndex($archivedFile['index'], PCLZIP_OPT_PATH, $documentDirectory, PCLZIP_OPT_REMOVE_ALL_PATH);
            //print basename($archivedFile['filename']).'<br />';
            if (stringEndsWith($archivedFile['filename'], 'xml') || basename($archivedFile['filename']) == 'thumbnail.png') {
                $oldPath = $documentDirectory . basename($archivedFile['filename']);
                $newPath = $documentDirectory . 'docvert-' . basename($archivedFile['filename']);
                if (!file_exists($oldPath)) {
                    webServiceError('&error-source-path-does-not-exist; "' . revealXml($oldPath) . '"');
                }
                rename($oldPath, $newPath);
                if (!file_exists(dirname($newPath))) {
                    webServiceError('&error-destination-directory-not-found;"' . revealXml(dirname($newPath)) . '"');
                }
                if (!file_exists($newPath)) {
                    webServiceError('&error-destination-path-not-exist; "' . revealXml($newPath) . '"');
                }
            } elseif (stringStartsWith(strtolower($archivedFile['filename']), 'objectreplacements')) {
                $oldPath = $documentDirectory . basename($archivedFile['filename']);
                if (!function_exists('getimagesize')) {
                    $template = '<div class="error"><p>&error-openoffice-objects;</p></div>';
                    $template = preg_replace_callback('/\\&(.*?)\\;/s', 'replaceLanguagePlaceholder', $template);
                    $testResultsPath = $documentDirectory . 'test.html';
                    file_put_contents($testResultsPath, $template, FILE_APPEND);
                } else {
                    $fileExtension = 'wmf';
                    $imageMetadata = null;
                    $imageSize = getimagesize($oldPath, $imageMetadata);
                    /*
                     * getimagesize returns a number which means a file format
                     * 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP,
                     * 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order),
                     * 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF,
                     * 15 = WBMP, 16 = XBM
                     */
                    $imageTypes = array("GIF", "JPG", "PNG", "SWF", "PSD", "BMP", "TIFF", "TIFF", "JPC", "JP2", "JPX", "JB2", "SWC", "IFF", "WBMP", "XBM");
                    if (count($imageMetadata) > 0) {
                        if (trim($imageMetadata[1]) != null && trim($imageMetadata[1]) != "" && $imageMetadata[1] < count($imageTypes)) {
                            $imageTypeIndex = $imageMetadata[1] - 1;
                            $fileExtension = strtolower($imageTypes[$imageTypeIndex]);
                            //die('File extension: "'.$fileExtension.':'.$imageTypes[$imageTypeIndex].'" ['.$imageMetadata[1].']');
                        }
                    } else {
                    }
                    $newPath = $documentDirectory . 'image' . $unknownImageIndex . '.' . $fileExtension;
                    $unknownImageIndex++;
                    $odfObjects[] = array($archivedFile['filename'], basename($newPath), $fileExtension);
                }
            }
        }
    }
    $contentXmlPath = $documentDirectory . 'docvert-content.xml';
    if (!file_exists($contentXmlPath)) {
        webServiceError('&error-no-content-xml-file-found;');
    }
    if (count($odfObjects) >= 1) {
        // Rename image paths
        $contentXml = file_get_contents($contentXmlPath);
        foreach ($odfObjects as $odfObject) {
            $contentXml = str_replace('./' . $odfObject[0] . '"', $odfObject[1] . '" type="' . $odfObject[2] . '"', $contentXml);
            $contentXml = str_replace($odfObject[0] . '"', $odfObject[1] . '" type="' . $odfObject[2] . '"', $contentXml);
        }
        //displayXmlString($contentXml);
        file_put_contents($contentXmlPath, $contentXml);
    }
}
开发者ID:Nolfneo,项目名称:docvert,代码行数:83,代码来源:lib.php


注:本文中的PclZip::extractByIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。